Skip to content

Commit

Permalink
Remove jsnext:main
Browse files Browse the repository at this point in the history
The field is deprecated and replaced with package.module. Additionally it caused many issues with packages that used it incorrectly. Fixes #844, #1037, #1048, #1062.
  • Loading branch information
devongovett committed May 2, 2018
1 parent e905ff1 commit f75941c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 30 deletions.
12 changes: 4 additions & 8 deletions src/Resolver.js
Original file line number Diff line number Diff line change
Expand Up @@ -268,15 +268,11 @@ class Resolver {

getPackageMain(pkg) {
// libraries like d3.js specifies node.js specific files in the "main" which breaks the build
// we use the "module" or "jsnext:main" field to get the full dependency tree if available.
// we use the "module" or "browser" field to get the full dependency tree if available.
// If this is a linked module with a `source` field, use that as the entry point.
let main = [
pkg.source,
pkg.module,
pkg['jsnext:main'],
pkg.browser,
pkg.main
].find(entry => typeof entry === 'string');
let main = [pkg.source, pkg.module, pkg.browser, pkg.main].find(
entry => typeof entry === 'string'
);

// Default to index file if no main field find
if (!main || main === '.' || main === './') {
Expand Down
23 changes: 1 addition & 22 deletions test/javascript.js
Original file line number Diff line number Diff line change
Expand Up @@ -542,28 +542,7 @@ describe('javascript', function() {
assert.equal(output.test(), 'pkg-es6-module');
});

it('should resolve the jsnext:main field before main', async function() {
let b = await bundle(
__dirname + '/integration/resolve-entries/jsnext-field.js'
);

assertBundleTree(b, {
name: 'jsnext-field.js',
assets: ['jsnext-field.js', 'jsnext.module.js'],
childBundles: [
{
type: 'map'
}
]
});

let output = run(b);

assert.equal(typeof output.test, 'function');
assert.equal(output.test(), 'pkg-jsnext-module');
});

it('should resolve the module field before jsnext:main', async function() {
it('should resolve the module field before main', async function() {
let b = await bundle(
__dirname + '/integration/resolve-entries/both-fields.js'
);
Expand Down

0 comments on commit f75941c

Please sign in to comment.