Skip to content

Commit 1753ed5

Browse files
committed
test(builtin): add browserify test to repro bazel-contrib#771
1 parent c1e3f4d commit 1753ed5

8 files changed

Lines changed: 251 additions & 23 deletions

File tree

‎internal/npm_install/BUILD.bazel‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ nodejs_binary(
3131
name = "browserify-wrapped",
3232
data = [
3333
":browserify-wrapped.js",
34-
"//third_party/github.com/browserify/browserify:sources",
34+
"//third_party/github.com/browserify/browserify:package_contents",
35+
"//third_party/github.com/jhermsmeier/browserify-named-amd:package_contents",
3536
],
3637
entry_point = ":browserify-wrapped.js",
3738
install_source_map_support = False,

‎internal/npm_install/test/BUILD.bazel‎

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,18 +34,26 @@ nodejs_binary(
3434
)
3535

3636
npm_umd_bundle(
37-
name = "some-bundle",
38-
package_name = "some-package-name",
37+
name = "test-minimist-bundling",
38+
package_name = "minimist",
3939
entry_point = "@npm//:node_modules/minimist/index.js",
4040
package = "@npm//minimist",
4141
)
4242

43+
npm_umd_bundle(
44+
name = "test-core-util-is-bundling",
45+
package_name = "core-util-is",
46+
entry_point = "@npm//:node_modules/core-util-is/lib/util.js",
47+
package = "@npm//core-util-is",
48+
)
49+
4350
jasmine_node_test(
4451
name = "browserify_test",
4552
srcs = ["browserify.spec.js"],
4653
data = [
47-
":some-package-name.umd.js",
54+
":core-util-is.umd.js",
55+
":minimist.umd.js",
4856
"//internal/npm_install:browserify-wrapped",
4957
"@npm//jasmine",
5058
],
51-
)
59+
)

‎internal/npm_install/test/browserify.spec.js‎

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,15 @@ describe('our bundled, vendored browserify binary', () => {
66
const idxFile = fs.readFileSync(require.resolve(mainFile), {encoding: 'utf-8'});
77
expect(idxFile).toContain('Copyright Joyent');
88
expect(idxFile).toMatch(/Copyright \d+ Mozilla/);
9-
expect(idxFile).toContain('Feross Aboukhadijeh');
9+
expect(idxFile).toContain('The Dojo Foundation');
10+
});
11+
it('should have a named AMD module', () => {
12+
const minimistUmd = require.resolve('build_bazel_rules_nodejs/internal/npm_install/test/minimist.umd.js');
13+
expect(fs.readFileSync(minimistUmd, {encoding: 'utf-8'})).toContain(`define('minimist'`);
1014
});
1115
it('should work', () => {
12-
const minimistUmd = require('build_bazel_rules_nodejs/internal/npm_install/test/some-package-name.umd.js');
13-
const result = minimistUmd('h');
16+
const minimist = require('build_bazel_rules_nodejs/internal/npm_install/test/minimist.umd.js');
17+
const result = minimist('h');
1418
expect(result._[0]).toBe('h');
1519
});
1620
});

‎package.json‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
"browserify": "16.2.3",
2121
"clang-format": "1.2.2",
2222
"conventional-changelog-cli": "^2.0.21",
23+
"core-util-is": "^1.0.2",
2324
"hello": "file:./tools/npm_packages/hello",
2425
"husky": "1.3.1",
2526
"is-builtin-module": "3.0.0",

‎third_party/github.com/browserify/browserify/BUILD.bazel‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@ exports_files(["LICENSE"])
1919

2020
filegroup(
2121
name = "package_contents",
22-
srcs = glob(["**/*.js"]) + [
22+
srcs = glob(["*.js"]) + [
2323
"advanced.txt",
2424
"BUILD.bazel",
2525
"LICENSE",
2626
"usage.txt",
2727
],
28-
visibility = ["//:__pkg__"],
28+
visibility = ["//:__subpackages__"],
2929
)

‎third_party/github.com/browserify/browserify/index.js‎

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3413,9 +3413,6 @@ exports.realpath = function realpath(p, cache, cb) {
34133413
}
34143414
};
34153415

3416-
if (!this._skipValidation) {
3417-
this._validateMapping(generated, original, source, name);
3418-
}
34193416

34203417
/***/ }),
34213418

@@ -12709,7 +12706,6 @@ pp$8.invalidStringToken = function(position, message) {
1270912706
} else {
1271012707
this.raise(position, message);
1271112708
}
12712-
return this;
1271312709
};
1271412710

1271512711
pp$8.readTmplToken = function() {
@@ -15440,7 +15436,6 @@ Glob.prototype._processReaddir2 = function (prefix, read, abs, remain, index, in
1544015436
// This was the last one, and no stats were needed
1544115437
return cb()
1544215438
}
15443-
inherits(P192, MPrime);
1544415439

1544515440
// now test all matched entries as stand-ins for that part
1544615441
// of the pattern.
@@ -22155,7 +22150,12 @@ function isNumber (x) {
2215522150
/***/ 731:
2215622151
/***/ (function(__unusedmodule, exports, __webpack_require__) {
2215722152

22158-
var inherits = __webpack_require__(207);
22153+
/* -*- Mode: js; js-indent-level: 2; -*- */
22154+
/*
22155+
* Copyright 2011 Mozilla Foundation and contributors
22156+
* Licensed under the New BSD license. See LICENSE or:
22157+
* http://opensource.org/licenses/BSD-3-Clause
22158+
*/
2215922159

2216022160
var util = __webpack_require__(913);
2216122161
var has = Object.prototype.hasOwnProperty;
@@ -22211,7 +22211,6 @@ ArraySet.prototype.add = function ArraySet_add(aStr, aAllowDuplicates) {
2221122211
} else {
2221222212
this._set[sStr] = idx;
2221322213
}
22214-
return objects.join(' ');
2221522214
}
2221622215
};
2221722216

@@ -22675,10 +22674,6 @@ module.exports = __webpack_require__(654).reduce(function (acc, x) {
2267522674
return acc;
2267622675
}, {});
2267722676

22678-
function hasOwnProperty(obj, prop) {
22679-
return Object.prototype.hasOwnProperty.call(obj, prop);
22680-
}
22681-
2268222677

2268322678
/***/ }),
2268422679

‎third_party/github.com/browserify/browserify/index.min.js‎

Lines changed: 220 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎yarn.lock‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1049,7 +1049,7 @@ core-js@^2.4.0, core-js@^2.5.0:
10491049
resolved "https://registry.yarnpkg.com/core-js/-/core-js-2.6.9.tgz#6b4b214620c834152e179323727fc19741b084f2"
10501050
integrity sha512-HOpZf6eXmnl7la+cUdMnLvUxKNqLUzJvgIziQ0DiF3JwSImNphIqdGqzj6hIKyX04MmV0poclQ7+wjWvxQyR2A==
10511051

1052-
core-util-is@~1.0.0:
1052+
core-util-is@^1.0.2, core-util-is@~1.0.0:
10531053
version "1.0.2"
10541054
resolved "https://registry.yarnpkg.com/core-util-is/-/core-util-is-1.0.2.tgz#b5fd54220aa2bc5ab57aab7140c940754503c1a7"
10551055
integrity sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=

0 commit comments

Comments
 (0)