From 517758d38391a1bdc33938fbb63194f7de0f0831 Mon Sep 17 00:00:00 2001 From: Keith Cirkel Date: Thu, 27 Sep 2018 12:18:34 +0100 Subject: [PATCH 1/3] feat: add `mainFields` api. Deprecate `browser`, `jsnext`, `module`, `main` --- README.md | 8 ++++ src/index.js | 52 ++++++++++++++++++-------- test/test.js | 104 +++++++++++++++++++++++++++++---------------------- 3 files changed, 104 insertions(+), 60 deletions(-) diff --git a/README.md b/README.md index 51d307c..25427f5 100644 --- a/README.md +++ b/README.md @@ -25,20 +25,28 @@ export default { name: 'MyModule', plugins: [ resolve({ + + // the fields to scan in a package.json to determine the entry point.. + mainFields: ['module', 'main'], // Default: ['module', 'main'] + + // DEPRECATED: use `mainFields` instead // use "module" field for ES6 module if possible module: true, // Default: true + // DEPRECATED: use `mainFields` instead // use "jsnext:main" if possible // legacy field pointing to ES6 module in third-party libraries, // deprecated in favor of "pkg.module": // - see: https://github.com/rollup/rollup/wiki/pkg.module jsnext: true, // Default: false + // DEPRECATED: use `mainFields` instead // use "main" field or index.js, even if it's not an ES6 module // (needs to be converted from CommonJS to ES6 // – see https://github.com/rollup/rollup-plugin-commonjs main: true, // Default: true + // DEPRECATED: use `mainFields` instead // some package.json files have a `browser` field which // specifies alternative files to load for people bundling // for the browser. If that's you, use this option, otherwise diff --git a/src/index.js b/src/index.js index 6b59116..3623d2b 100644 --- a/src/index.js +++ b/src/index.js @@ -37,12 +37,29 @@ function cachedIsFile (file, cb) { isFileCache[file].then(contents => cb(null, contents), cb); } +function deprecatedMainField (options, option, mainFields, field = option) { + if (option in options) { + CONSOLE_WARN(`node-resolve: setting options.${option} is deprecated, please override options.mainFields instead`); + if (options[option] === false) { + return mainFields.filter(mainField => mainField === field); + } else if (options[option] === true && mainFields.indexOf(field) === -1) { + return mainFields.concat([field]); + } + } + return mainFields; +} + const resolveIdAsync = (file, opts) => new Promise((fulfil, reject) => resolveId(file, opts, (err, contents) => err ? reject(err) : fulfil(contents))); export default function nodeResolve ( options = {} ) { - const useModule = options.module !== false; - const useMain = options.main !== false; - const useJsnext = options.jsnext === true; + if ('mainFields' in options && ('module' in options || 'main' in options || 'jsnext' in options)) { + throw new Error(`node-resolve: do not use deprecated 'module', 'main', 'jsnext' options with 'mainFields'`); + } + let mainFields = options.mainFields || ['module', 'main']; + mainFields = deprecatedMainField(options, 'browser', mainFields); + mainFields = deprecatedMainField(options, 'module', mainFields); + mainFields = deprecatedMainField(options, 'jsnext', mainFields, 'jsnext:main'); + mainFields = deprecatedMainField(options, 'main', mainFields); const isPreferBuiltinsSet = options.preferBuiltins === true || options.preferBuiltins === false; const preferBuiltins = isPreferBuiltinsSet ? options.preferBuiltins : true; const customResolveOptions = options.customResolveOptions || {}; @@ -59,8 +76,8 @@ export default function nodeResolve ( options = {} ) { throw new Error( 'options.skip is no longer supported — you should use the main Rollup `external` option instead' ); } - if ( !useModule && !useMain && !useJsnext ) { - throw new Error( `At least one of options.module, options.main or options.jsnext must be true` ); + if ( !mainFields.length ) { + throw new Error( `Please ensure at least one 'mainFields' value is specified` ); } let preserveSymlinks; @@ -82,8 +99,8 @@ export default function nodeResolve ( options = {} ) { const basedir = importer ? dirname( importer ) : process.cwd(); - if (options.browser && browserMapCache[importer]) { - const resolvedImportee = resolve( basedir, importee ); + if (mainFields.indexOf('browser') !== -1 && browserMapCache[importer]) { + const resolvedImportee = resolve( basedir, importee ); const browser = browserMapCache[importer]; if (browser[importee] === false || browser[resolvedImportee] === false) { return ES6_BROWSER_EMPTY; @@ -115,7 +132,7 @@ export default function nodeResolve ( options = {} ) { basedir, packageFilter ( pkg, pkgPath ) { const pkgRoot = dirname( pkgPath ); - if (options.browser && typeof pkg[ 'browser' ] === 'object') { + if (mainFields.indexOf('browser') !== -1 && typeof pkg[ 'browser' ] === 'object') { packageBrowserField = Object.keys(pkg[ 'browser' ]).reduce((browser, key) => { const resolved = pkg[ 'browser' ][ key ] === false ? false : resolve( pkgRoot, pkg[ 'browser' ][ key ] ); browser[ key ] = resolved; @@ -133,13 +150,16 @@ export default function nodeResolve ( options = {} ) { }, {}); } - if (options.browser && typeof pkg[ 'browser' ] === 'string') { - pkg[ 'main' ] = pkg[ 'browser' ]; - } else if ( useModule && pkg[ 'module' ] ) { - pkg[ 'main' ] = pkg[ 'module' ]; - } else if ( useJsnext && pkg[ 'jsnext:main' ] ) { - pkg[ 'main' ] = pkg[ 'jsnext:main' ]; - } else if ( ( useJsnext || useModule ) && !useMain ) { + let overriddenMain = false; + for ( const i in mainFields ) { + const field = mainFields[i]; + if ( typeof pkg[ field ] === 'string' ) { + pkg[ 'main' ] = pkg[ field ]; + overriddenMain = true; + break; + } + } + if ( overriddenMain === false && mainFields.indexOf( 'main' ) === -1 ) { disregardResult = true; } return pkg; @@ -159,7 +179,7 @@ export default function nodeResolve ( options = {} ) { ) .catch(() => false) .then(resolved => { - if (options.browser && packageBrowserField) { + if (mainFields.indexOf('browser') !== -1 && packageBrowserField) { if (packageBrowserField[ resolved ]) { resolved = packageBrowserField[ resolved ]; } diff --git a/test/test.js b/test/test.js index fbf6c2f..c8b6755 100644 --- a/test/test.js +++ b/test/test.js @@ -37,6 +37,17 @@ function getBundleImports ( bundle) { describe( 'rollup-plugin-node-resolve', function () { it( 'finds a module with jsnext:main', function () { + return rollup.rollup({ + input: 'samples/jsnext/main.js', + plugins: [ + nodeResolve({ mainFields: ['jsnext:main', 'module', 'main'] }) + ] + }).then( executeBundle ).then( module => { + assert.equal( module.exports, '2H' ); + }); + }); + + it( 'DEPRECATED: options.jsnext still works', function () { return rollup.rollup({ input: 'samples/jsnext/main.js', plugins: [ @@ -51,7 +62,7 @@ describe( 'rollup-plugin-node-resolve', function () { return rollup.rollup({ input: 'samples/commonjs/main.js', plugins: [ - nodeResolve({ main: true }), + nodeResolve({ mainFields: ['main'] }), commonjs() ] }).then( executeBundle ).then( module => { @@ -63,7 +74,7 @@ describe( 'rollup-plugin-node-resolve', function () { return rollup.rollup({ input: 'samples/trailing-slash/main.js', plugins: [ - nodeResolve({ main: true }), + nodeResolve({ mainFields: ['main'] }), commonjs() ] }).then( executeBundle ).then( module => { @@ -113,10 +124,7 @@ describe( 'rollup-plugin-node-resolve', function () { return rollup.rollup({ input: 'samples/browser/main.js', plugins: [ - nodeResolve({ - main: true, - browser: false - }) + nodeResolve() ] }).then( executeBundle ).then( module => { assert.equal( module.exports, 'node' ); @@ -128,8 +136,7 @@ describe( 'rollup-plugin-node-resolve', function () { input: 'samples/browser/main.js', plugins: [ nodeResolve({ - main: true, - browser: true + mainFields: [ 'browser', 'main' ] }) ] }).then( executeBundle ).then( module => { @@ -141,10 +148,7 @@ describe( 'rollup-plugin-node-resolve', function () { return rollup.rollup({ input: 'samples/browser-object/main.js', plugins: [ - nodeResolve({ - main: true, - browser: false - }) + nodeResolve() ] }).then( executeBundle ).then( module => { assert.equal( module.exports.env, 'node' ); @@ -158,8 +162,7 @@ describe( 'rollup-plugin-node-resolve', function () { input: 'samples/browser-object/main.js', plugins: [ nodeResolve({ - main: true, - browser: true + mainFields: [ 'browser', 'main' ] }) ] }).then( executeBundle ).then( module => { @@ -174,7 +177,21 @@ describe( 'rollup-plugin-node-resolve', function () { input: 'samples/browser-object-main/main.js', plugins: [ nodeResolve({ - main: true, + mainFields: [ 'browser', 'main' ] + }) + ] + }).then( executeBundle ).then( module => { + assert.equal( module.exports.env, 'browser' ); + assert.equal( module.exports.dep, 'browser-dep' ); + assert.equal( module.exports.test, 43 ); + }); + }); + + it( 'DEPRECATED: options.browser = true still works', function () { + return rollup.rollup({ + entry: 'samples/browser-object-main/main.js', + plugins: [ + nodeResolve({ browser: true }) ] @@ -190,8 +207,7 @@ describe( 'rollup-plugin-node-resolve', function () { input: 'samples/browser-object/main-implicit.js', plugins: [ nodeResolve({ - main: true, - browser: true + mainFields: [ 'browser', 'main' ] }) ] }).then( executeBundle ).then( module => { @@ -204,8 +220,7 @@ describe( 'rollup-plugin-node-resolve', function () { input: 'samples/browser-object-builtin/main.js', plugins: [ nodeResolve({ - main: true, - browser: true + mainFields: [ 'browser', 'main' ] }) ] }).then( executeBundle ).then( module => { @@ -218,8 +233,7 @@ describe( 'rollup-plugin-node-resolve', function () { input: 'samples/browser-object-nested/main.js', plugins: [ nodeResolve({ - main: true, - browser: true + mainFields: [ 'browser', 'main' ] }) ] }).then( executeBundle ).then( module => { @@ -234,8 +248,7 @@ describe( 'rollup-plugin-node-resolve', function () { input: 'samples/browser-object-main/main.js', plugins: [ nodeResolve({ - main: true, - browser: true + mainFields: [ 'browser', 'main' ] }) ] }).then( executeBundle ).then( module => { @@ -250,8 +263,7 @@ describe( 'rollup-plugin-node-resolve', function () { input: 'samples/browser-object/main-implicit.js', plugins: [ nodeResolve({ - main: true, - browser: true + mainFields: [ 'browser', 'main' ] }) ] }).then( executeBundle ).then( module => { @@ -264,8 +276,7 @@ describe( 'rollup-plugin-node-resolve', function () { input: 'samples/browser-object-builtin/main.js', plugins: [ nodeResolve({ - main: true, - browser: true + mainFields: [ 'browser', 'main' ] }) ] }).then( executeBundle ).then( module => { @@ -278,8 +289,7 @@ describe( 'rollup-plugin-node-resolve', function () { input: 'samples/browser-object-nested/main.js', plugins: [ nodeResolve({ - main: true, - browser: true + mainFields: [ 'browser', 'main' ] }) ] }).then( executeBundle ).then( module => { @@ -294,8 +304,7 @@ describe( 'rollup-plugin-node-resolve', function () { input: 'samples/browser-object-main/main.js', plugins: [ nodeResolve({ - main: true, - browser: true + mainFields: [ 'browser', 'main' ] }) ] }).then( executeBundle ).then( module => { @@ -310,8 +319,7 @@ describe( 'rollup-plugin-node-resolve', function () { input: 'samples/browser-object/main-implicit.js', plugins: [ nodeResolve({ - main: true, - browser: true + mainFields: [ 'browser', 'main' ] }) ] }).then( executeBundle ).then( module => { @@ -324,8 +332,7 @@ describe( 'rollup-plugin-node-resolve', function () { input: 'samples/browser-object-builtin/main.js', plugins: [ nodeResolve({ - main: true, - browser: true + mainFields: [ 'browser', 'main' ] }) ] }).then( executeBundle ).then( module => { @@ -338,8 +345,7 @@ describe( 'rollup-plugin-node-resolve', function () { input: 'samples/browser-object-nested/main.js', plugins: [ nodeResolve({ - main: true, - browser: true + mainFields: [ 'browser', 'main' ] }) ] }).then( executeBundle ).then( module => { @@ -354,8 +360,7 @@ describe( 'rollup-plugin-node-resolve', function () { input: 'samples/browser-false/main.js', plugins: [ nodeResolve({ - main: true, - browser: true + mainFields: [ 'browser', 'main' ] }) ] }).then( executeBundle ); @@ -434,11 +439,11 @@ describe( 'rollup-plugin-node-resolve', function () { }); }); - it( 'prefers module field over jsnext:main and main', () => { + it( 'respects order if given module,jsnext:main,main', () => { return rollup.rollup({ input: 'samples/prefer-module/main.js', plugins: [ - nodeResolve({ jsnext: true, preferBuiltins: false }) + nodeResolve({ mainFields: [ 'module', 'jsnext:main', 'main' ], preferBuiltins: false }) ] }).then( executeBundle ).then( module => { assert.equal( module.exports, 'MODULE-ENTRY' ); @@ -467,6 +472,17 @@ describe( 'rollup-plugin-node-resolve', function () { }); }); + it( 'keeps the order of [browser, module, jsnext, main] with all enabled', function () { + return rollup.rollup({ + input: 'samples/browser/main.js', + plugins: [ + nodeResolve({ main: true, browser: true, jsnext: true, module: true }) + ] + }).then( executeBundle ).then( module => { + assert.equal( module.exports, 'node' ); + }); + }); + describe( 'symlinks', () => { function createMissingDirectories () { createDirectory( './samples/symlinked/first/node_modules' ); @@ -525,11 +541,11 @@ describe( 'rollup-plugin-node-resolve', function () { }); }); - it( 'prefers jsnext:main field over main', () => { + it( 'respects order if given jsnext:main, main', () => { return rollup.rollup({ input: 'samples/prefer-jsnext/main.js', plugins: [ - nodeResolve({ jsnext: true, module: false, preferBuiltins: false }) + nodeResolve({ mainFields: ['jsnext:main', 'main'], preferBuiltins: false }) ] }).then( executeBundle ).then( module => { assert.equal( module.exports, 'JSNEXT-ENTRY' ); @@ -540,7 +556,7 @@ describe( 'rollup-plugin-node-resolve', function () { return rollup.rollup({ input: './samples/jsnext/main.js', plugins: [ - nodeResolve({ jsnext: true }) + nodeResolve({}) ] }).then( executeBundle ).then( module => { assert.equal( module.exports, '2H' ); From 06e961c1fa822c14f6893125e69502524db9771e Mon Sep 17 00:00:00 2001 From: Lukas Taegert-Atkinson Date: Fri, 5 Apr 2019 07:39:32 +0200 Subject: [PATCH 2/3] Fix remaining issues with mainfields --- README.md | 19 +++++++++--------- src/index.js | 56 ++++++++++++++++++++++++++++++---------------------- test/test.js | 10 +++++----- 3 files changed, 47 insertions(+), 38 deletions(-) diff --git a/README.md b/README.md index 25427f5..4c77a94 100644 --- a/README.md +++ b/README.md @@ -26,31 +26,32 @@ export default { plugins: [ resolve({ - // the fields to scan in a package.json to determine the entry point.. + // the fields to scan in a package.json to determine the entry point + // if this list contains "browser", overrides specified in "pkg.browser" + // will be used mainFields: ['module', 'main'], // Default: ['module', 'main'] - // DEPRECATED: use `mainFields` instead + // DEPRECATED: use "mainFields" instead // use "module" field for ES6 module if possible module: true, // Default: true - // DEPRECATED: use `mainFields` instead + // DEPRECATED: use "mainFields" instead // use "jsnext:main" if possible // legacy field pointing to ES6 module in third-party libraries, // deprecated in favor of "pkg.module": // - see: https://github.com/rollup/rollup/wiki/pkg.module jsnext: true, // Default: false - // DEPRECATED: use `mainFields` instead + // DEPRECATED: use "mainFields" instead // use "main" field or index.js, even if it's not an ES6 module // (needs to be converted from CommonJS to ES6 // – see https://github.com/rollup/rollup-plugin-commonjs main: true, // Default: true - // DEPRECATED: use `mainFields` instead - // some package.json files have a `browser` field which - // specifies alternative files to load for people bundling - // for the browser. If that's you, use this option, otherwise - // pkg.browser will be ignored + // some package.json files have a "browser" field which specifies + // alternative files to load for people bundling for the browser. If + // that's you, either use this option or add "browser" to the + // "mainfields" option, otherwise pkg.browser will be ignored browser: true, // Default: false // not all files you want to resolve are .js files diff --git a/src/index.js b/src/index.js index a92ef53..d973d7e 100644 --- a/src/index.js +++ b/src/index.js @@ -37,14 +37,32 @@ function cachedIsFile (file, cb) { isFileCache[file].then(contents => cb(null, contents), cb); } -function deprecatedMainField (options, option, mainFields, field = option) { - if (option in options) { - CONSOLE_WARN(`node-resolve: setting options.${option} is deprecated, please override options.mainFields instead`); - if (options[option] === false) { - return mainFields.filter(mainField => mainField === field); - } else if (options[option] === true && mainFields.indexOf(field) === -1) { - return mainFields.concat([field]); +function getMainFields (options) { + let mainFields; + if (options.mainFields) { + if ('module' in options || 'main' in options || 'jsnext' in options) { + throw new Error(`node-resolve: do not use deprecated 'module', 'main', 'jsnext' options with 'mainFields'`); } + mainFields = options.mainFields; + } else { + mainFields = ['module', 'main']; + [['module', 'module'], ['jsnext', 'jsnext:main'], ['main', 'main']].forEach(([option, field]) => { + if (option in options) { + // eslint-disable-next-line no-console + console.warn(`node-resolve: setting options.${option} is deprecated, please override options.mainFields instead`); + if (options[option] === false) { + mainFields = mainFields.filter(mainField => mainField === field); + } else if (options[option] === true && mainFields.indexOf(field) === -1) { + mainFields.push(field); + } + } + }); + } + if (options.browser && mainFields.indexOf('browser') === -1) { + return ['browser'].concat(mainFields); + } + if ( !mainFields.length ) { + throw new Error( `Please ensure at least one 'mainFields' value is specified` ); } return mainFields; } @@ -52,14 +70,8 @@ function deprecatedMainField (options, option, mainFields, field = option) { const resolveIdAsync = (file, opts) => new Promise((fulfil, reject) => resolveId(file, opts, (err, contents) => err ? reject(err) : fulfil(contents))); export default function nodeResolve ( options = {} ) { - if ('mainFields' in options && ('module' in options || 'main' in options || 'jsnext' in options)) { - throw new Error(`node-resolve: do not use deprecated 'module', 'main', 'jsnext' options with 'mainFields'`); - } - let mainFields = options.mainFields || ['module', 'main']; - mainFields = deprecatedMainField(options, 'browser', mainFields); - mainFields = deprecatedMainField(options, 'module', mainFields); - mainFields = deprecatedMainField(options, 'jsnext', mainFields, 'jsnext:main'); - mainFields = deprecatedMainField(options, 'main', mainFields); + const mainFields = getMainFields(options); + const useBrowserOverrides = mainFields.indexOf('browser') !== -1; const isPreferBuiltinsSet = options.preferBuiltins === true || options.preferBuiltins === false; const preferBuiltins = isPreferBuiltinsSet ? options.preferBuiltins : true; const customResolveOptions = options.customResolveOptions || {}; @@ -76,10 +88,6 @@ export default function nodeResolve ( options = {} ) { throw new Error( 'options.skip is no longer supported — you should use the main Rollup `external` option instead' ); } - if ( !mainFields.length ) { - throw new Error( `Please ensure at least one 'mainFields' value is specified` ); - } - let preserveSymlinks; return { @@ -100,8 +108,8 @@ export default function nodeResolve ( options = {} ) { const basedir = importer ? dirname( importer ) : process.cwd(); // https://github.com/defunctzombie/package-browser-field-spec - if (mainFields.indexOf('browser') !== -1 && browserMapCache[importer]) { - const resolvedImportee = resolve( basedir, importee ); + if (useBrowserOverrides && browserMapCache[importer]) { + const resolvedImportee = resolve( basedir, importee ); const browser = browserMapCache[importer]; if (browser[importee] === false || browser[resolvedImportee] === false) { return ES6_BROWSER_EMPTY; @@ -132,7 +140,7 @@ export default function nodeResolve ( options = {} ) { basedir, packageFilter ( pkg, pkgPath ) { const pkgRoot = dirname( pkgPath ); - if (mainFields.indexOf('browser') !== -1 && typeof pkg[ 'browser' ] === 'object') { + if (useBrowserOverrides && typeof pkg[ 'browser' ] === 'object') { packageBrowserField = Object.keys(pkg[ 'browser' ]).reduce((browser, key) => { let resolved = pkg[ 'browser' ][ key ]; if (resolved && resolved[0] === '.') { @@ -154,7 +162,7 @@ export default function nodeResolve ( options = {} ) { } let overriddenMain = false; - for ( const i in mainFields ) { + for ( let i = 0; i < mainFields.length; i++ ) { const field = mainFields[i]; if ( typeof pkg[ field ] === 'string' ) { pkg[ 'main' ] = pkg[ field ]; @@ -181,7 +189,7 @@ export default function nodeResolve ( options = {} ) { Object.assign( resolveOptions, customResolveOptions ) ) .then(resolved => { - if ( resolved && mainFields.indexOf('browser') !== -1 && packageBrowserField ) { + if ( resolved && useBrowserOverrides && packageBrowserField ) { if ( packageBrowserField.hasOwnProperty(resolved) ) { if (!packageBrowserField[resolved]) { browserMapCache[resolved] = packageBrowserField; diff --git a/test/test.js b/test/test.js index 15ca34e..2b5ec60 100644 --- a/test/test.js +++ b/test/test.js @@ -140,7 +140,7 @@ describe( 'rollup-plugin-node-resolve', function () { }); }); - it( 'disregards top-level browser field by default', function () { + it( 'disregards top-level browser field', function () { return rollup.rollup({ input: 'samples/browser/main.js', onwarn: expectNoWarnings, @@ -166,7 +166,7 @@ describe( 'rollup-plugin-node-resolve', function () { }); }); - it( 'disregards object browser field by default', function () { + it( 'disregards object browser field', function () { return rollup.rollup({ input: 'samples/browser-object/main.js', onwarn: expectNoWarnings, @@ -212,9 +212,9 @@ describe( 'rollup-plugin-node-resolve', function () { }); }); - it( 'DEPRECATED: options.browser = true still works', function () { + it( 'options.browser = true still works', function () { return rollup.rollup({ - entry: 'samples/browser-object-main/main.js', + input: 'samples/browser-object-main/main.js', plugins: [ nodeResolve({ browser: true @@ -543,7 +543,7 @@ describe( 'rollup-plugin-node-resolve', function () { nodeResolve({ main: true, browser: true, jsnext: true, module: true }) ] }).then( executeBundle ).then( module => { - assert.equal( module.exports, 'node' ); + assert.equal( module.exports, 'browser' ); }); }); From 6accfb15d026ad02798386799fc0a97a74ce8886 Mon Sep 17 00:00:00 2001 From: Lukas Taegert-Atkinson Date: Fri, 5 Apr 2019 08:09:55 +0200 Subject: [PATCH 3/3] Add new option to types --- index.d.ts | 22 ++++++++++++++++------ package-lock.json | 3 +-- 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/index.d.ts b/index.d.ts index b1d3faa..dda9a21 100644 --- a/index.d.ts +++ b/index.d.ts @@ -1,13 +1,22 @@ -import { Plugin } from 'rollup'; -import { AsyncOpts } from 'resolve'; +import {Plugin} from 'rollup'; +import {AsyncOpts} from 'resolve'; interface RollupNodeResolveOptions { /** + * the fields to scan in a package.json to determine the entry point + * if this list contains "browser", overrides specified in "pkg.browser" + * will be used + * @default ['module', 'main'] + */ + mainFields?: ['browser', 'esnext', 'module', 'main'], + /** + * @deprecated use "mainFields" instead * use "module" field for ES6 module if possible * @default true */ module?: boolean; /** + * @deprecated use "mainFields" instead * use "jsnext:main" if possible * legacy field pointing to ES6 module in third-party libraries, * deprecated in favor of "pkg.module": @@ -16,6 +25,7 @@ interface RollupNodeResolveOptions { */ jsnext?: boolean; /** + * @deprecated use "mainFields" instead * use "main" field or index.js, even if it's not an ES6 module * (needs to be converted from CommonJS to ES6) * – see https://github.com/rollup/rollup-plugin-commonjs @@ -23,10 +33,10 @@ interface RollupNodeResolveOptions { */ main?: boolean; /** - * some package.json files have a `browser` field which - * specifies alternative files to load for people bundling - * for the browser. If that's you, use this option, otherwise - * pkg.browser will be ignored + * some package.json files have a "browser" field which specifies + * alternative files to load for people bundling for the browser. If + * that's you, either use this option or add "browser" to the + * "mainfields" option, otherwise pkg.browser will be ignored * @default false */ browser?: boolean; diff --git a/package-lock.json b/package-lock.json index 7b116d9..7e9603d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -33,8 +33,7 @@ "@types/node": { "version": "11.13.0", "resolved": "https://registry.npmjs.org/@types/node/-/node-11.13.0.tgz", - "integrity": "sha512-rx29MMkRdVmzunmiA4lzBYJNnXsW/PhG4kMBy2ATsYaDjGGR75dCFEVVROKpNwlVdcUX3xxlghKQOeDPBJobng==", - "dev": true + "integrity": "sha512-rx29MMkRdVmzunmiA4lzBYJNnXsW/PhG4kMBy2ATsYaDjGGR75dCFEVVROKpNwlVdcUX3xxlghKQOeDPBJobng==" }, "@types/resolve": { "version": "0.0.8",