From 2d06c44874c17effe5c2724742c69d6a4cd11e95 Mon Sep 17 00:00:00 2001 From: Lukas Taegert-Atkinson Date: Wed, 10 Mar 2021 16:23:36 +0100 Subject: [PATCH] feat(commonjs)!: Add ignore-dynamic-requires option (#819) BREAKING CHANGES: When dynamicRequireTargets is specified, "require" will be default no longer be used as fallback --- packages/commonjs/README.md | 19 + packages/commonjs/src/helpers.js | 16 +- packages/commonjs/src/index.js | 7 +- packages/commonjs/src/transform-commonjs.js | 15 +- .../dynamic-require-absolute-paths/_config.js | 9 - .../dynamic-require-absolute-paths/main.js | 7 - .../submodule.js | 1 - .../dynamic-require-fallback/_config.js | 6 + .../function/dynamic-require-fallback/dep.js | 1 + .../function/dynamic-require-fallback/main.js | 8 + .../function/dynamic-require-globs/main.js | 13 +- .../dynamic-require-no-fallback/_config.js | 3 + .../dynamic-require-no-fallback/main.js | 10 + .../_config.js | 7 + .../dynamic-require-targets-fallback/dep1.js | 1 + .../dynamic-require-targets-fallback/dep2.js | 1 + .../dynamic-require-targets-fallback/main.js | 9 + .../_config.js | 7 + .../dep1.js | 1 + .../main.js | 11 + .../function/global-not-overwritten/encode.js | 2 +- .../test/fixtures/function/inline/main.js | 2 +- .../test/fixtures/function/inline/multiply.js | 2 +- .../function/toplevel-return-complex/bar.js | 2 +- .../unsupported-dynamic-require/_config.js | 3 - .../unsupported-dynamic-require/main.js | 10 - .../submodule2.js | 2 +- .../fixtures/samples/umd/correct-scoping.js | 2 +- packages/commonjs/test/form.js | 11 +- .../commonjs/test/snapshots/function.js.md | 1023 ++++++++++------- .../commonjs/test/snapshots/function.js.snap | Bin 15006 -> 15704 bytes packages/commonjs/test/types.ts | 1 + packages/commonjs/types/index.d.ts | 15 +- 33 files changed, 761 insertions(+), 466 deletions(-) delete mode 100755 packages/commonjs/test/fixtures/function/dynamic-require-absolute-paths/_config.js delete mode 100755 packages/commonjs/test/fixtures/function/dynamic-require-absolute-paths/main.js delete mode 100755 packages/commonjs/test/fixtures/function/dynamic-require-absolute-paths/submodule.js create mode 100755 packages/commonjs/test/fixtures/function/dynamic-require-fallback/_config.js create mode 100755 packages/commonjs/test/fixtures/function/dynamic-require-fallback/dep.js create mode 100755 packages/commonjs/test/fixtures/function/dynamic-require-fallback/main.js create mode 100755 packages/commonjs/test/fixtures/function/dynamic-require-no-fallback/_config.js create mode 100755 packages/commonjs/test/fixtures/function/dynamic-require-no-fallback/main.js create mode 100755 packages/commonjs/test/fixtures/function/dynamic-require-targets-fallback/_config.js create mode 100755 packages/commonjs/test/fixtures/function/dynamic-require-targets-fallback/dep1.js create mode 100755 packages/commonjs/test/fixtures/function/dynamic-require-targets-fallback/dep2.js create mode 100755 packages/commonjs/test/fixtures/function/dynamic-require-targets-fallback/main.js create mode 100755 packages/commonjs/test/fixtures/function/dynamic-require-targets-no-fallback/_config.js create mode 100755 packages/commonjs/test/fixtures/function/dynamic-require-targets-no-fallback/dep1.js create mode 100755 packages/commonjs/test/fixtures/function/dynamic-require-targets-no-fallback/main.js delete mode 100755 packages/commonjs/test/fixtures/function/unsupported-dynamic-require/_config.js delete mode 100755 packages/commonjs/test/fixtures/function/unsupported-dynamic-require/main.js diff --git a/packages/commonjs/README.md b/packages/commonjs/README.md index dd3bddd7e..6aff1ee2e 100644 --- a/packages/commonjs/README.md +++ b/packages/commonjs/README.md @@ -134,6 +134,25 @@ Due to the conversion of `require` to a static `import` - the call is hoisted to - `string[]`: Pass an array containing the IDs to left unconverted. - `((id: string) => boolean|'remove')`: Pass a function that control individual IDs. +### `ignoreDynamicRequires` + +Type: `boolean` +Default: false + +Some `require` calls cannot be resolved statically to be translated to imports, e.g. + +```js +function wrappedRequire(target) { + return require(target); +} +wrappedRequire('foo'); +wrappedRequire('bar'); +``` + +When this option is set to `false`, the generated code will either directly throw an error when such a call is encountered or, when `dynamicRequireTargets` is used, when such a call cannot be resolved with a configured dynamic require target. + +Setting this option to `true` will instead leave the `require` call in the code or use it as a fallback for `dynamicRequireTargets`. + ### `esmExternals` Type: `boolean | string[] | ((id: string) => boolean)` diff --git a/packages/commonjs/src/helpers.js b/packages/commonjs/src/helpers.js index c57f142ee..b4c17ccd2 100644 --- a/packages/commonjs/src/helpers.js +++ b/packages/commonjs/src/helpers.js @@ -48,18 +48,20 @@ export function getAugmentedNamespace(n) { } `; +const FAILED_REQUIRE_ERROR = `throw new Error('Could not dynamically require "' + path + '". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.');`; + const HELPER_NON_DYNAMIC = ` export function createCommonjsModule(fn) { var module = { exports: {} } return fn(module, module.exports), module.exports; } -export function commonjsRequire (target) { - throw new Error('Could not dynamically require "' + target + '". Please configure the dynamicRequireTargets option of @rollup/plugin-commonjs appropriately for this require call to behave properly.'); +export function commonjsRequire (path) { + ${FAILED_REQUIRE_ERROR} } `; -const HELPERS_DYNAMIC = ` +const getDynamicHelpers = (ignoreDynamicRequires) => ` export function createCommonjsModule(fn, basedir, module) { return module = { path: basedir, @@ -231,13 +233,15 @@ export function commonjsRequire (path, originalModuleDir) { return cachedModule.exports; }; } - return require(path); + ${ignoreDynamicRequires ? 'return require(path);' : FAILED_REQUIRE_ERROR} } commonjsRequire.cache = DYNAMIC_REQUIRE_CACHE; commonjsRequire.resolve = commonjsResolve; `; -export function getHelpersModule(isDynamicRequireModulesEnabled) { - return `${HELPERS}${isDynamicRequireModulesEnabled ? HELPERS_DYNAMIC : HELPER_NON_DYNAMIC}`; +export function getHelpersModule(isDynamicRequireModulesEnabled, ignoreDynamicRequires) { + return `${HELPERS}${ + isDynamicRequireModulesEnabled ? getDynamicHelpers(ignoreDynamicRequires) : HELPER_NON_DYNAMIC + }`; } diff --git a/packages/commonjs/src/index.js b/packages/commonjs/src/index.js index ed307c90f..79015294b 100644 --- a/packages/commonjs/src/index.js +++ b/packages/commonjs/src/index.js @@ -44,6 +44,7 @@ export default function commonjs(options = {}) { const filter = createFilter(options.include, options.exclude); const { ignoreGlobal, + ignoreDynamicRequires, requireReturnsDefault: requireReturnsDefaultOption, esmExternals } = options; @@ -97,6 +98,7 @@ export default function commonjs(options = {}) { function transformAndCheckExports(code, id) { if (isDynamicRequireModulesEnabled && this.getModuleInfo(id).isEntry) { + // eslint-disable-next-line no-param-reassign code = getDynamicPackagesEntryIntro(dynamicRequireModuleDirPaths, dynamicRequireModuleSet) + code; } @@ -125,6 +127,7 @@ export default function commonjs(options = {}) { // avoid wrapping in createCommonjsModule, as this is a commonjsRegister call if (isModuleRegisterProxy(id)) { disableWrap = true; + // eslint-disable-next-line no-param-reassign id = unwrapModuleRegisterProxy(id); } @@ -135,6 +138,7 @@ export default function commonjs(options = {}) { isEsModule, ignoreGlobal || isEsModule, ignoreRequire, + ignoreDynamicRequires && !isDynamicRequireModulesEnabled, getIgnoreTryCatchRequireStatementMode, sourceMap, isDynamicRequireModulesEnabled, @@ -161,7 +165,7 @@ export default function commonjs(options = {}) { load(id) { if (id === HELPERS_ID) { - return getHelpersModule(isDynamicRequireModulesEnabled); + return getHelpersModule(isDynamicRequireModulesEnabled, ignoreDynamicRequires); } if (id.startsWith(HELPERS_ID)) { @@ -232,6 +236,7 @@ export default function commonjs(options = {}) { } }, + // eslint-disable-next-line no-shadow moduleParsed({ id, meta: { commonjs } }) { if (commonjs) { const isCjs = commonjs.isCommonJS; diff --git a/packages/commonjs/src/transform-commonjs.js b/packages/commonjs/src/transform-commonjs.js index 0f6b54060..ccb32a565 100644 --- a/packages/commonjs/src/transform-commonjs.js +++ b/packages/commonjs/src/transform-commonjs.js @@ -46,6 +46,7 @@ export default function transformCommonjs( isEsModule, ignoreGlobal, ignoreRequire, + ignoreDynamicRequires, getIgnoreTryCatchRequireStatementMode, sourceMap, isDynamicRequireModulesEnabled, @@ -320,12 +321,14 @@ export default function transformCommonjs( )}` ); } - if (isShorthandProperty(parent)) { - magicString.appendRight(node.end, `: ${HELPERS_NAME}.commonjsRequire`); - } else { - magicString.overwrite(node.start, node.end, `${HELPERS_NAME}.commonjsRequire`, { - storeName: true - }); + if (!ignoreDynamicRequires) { + if (isShorthandProperty(parent)) { + magicString.appendRight(node.end, `: ${HELPERS_NAME}.commonjsRequire`); + } else { + magicString.overwrite(node.start, node.end, `${HELPERS_NAME}.commonjsRequire`, { + storeName: true + }); + } } uses.commonjsHelpers = true; diff --git a/packages/commonjs/test/fixtures/function/dynamic-require-absolute-paths/_config.js b/packages/commonjs/test/fixtures/function/dynamic-require-absolute-paths/_config.js deleted file mode 100755 index c0a5a9fc2..000000000 --- a/packages/commonjs/test/fixtures/function/dynamic-require-absolute-paths/_config.js +++ /dev/null @@ -1,9 +0,0 @@ -module.exports = { - description: 'resolves both windows and posix absolute paths', - pluginOptions: { - dynamicRequireTargets: ['fixtures/function/dynamic-require-absolute-paths/submodule.js'] - }, - options: { - external: ['path'] - } -}; diff --git a/packages/commonjs/test/fixtures/function/dynamic-require-absolute-paths/main.js b/packages/commonjs/test/fixtures/function/dynamic-require-absolute-paths/main.js deleted file mode 100755 index b5653b870..000000000 --- a/packages/commonjs/test/fixtures/function/dynamic-require-absolute-paths/main.js +++ /dev/null @@ -1,7 +0,0 @@ -/* eslint-disable import/no-dynamic-require, global-require */ - -const Path = require('path'); - -const basePath = `${process.cwd()}/fixtures/function/dynamic-require-absolute-paths`; - -t.is(require(Path.resolve(`${basePath}/submodule.js`)), 'submodule'); diff --git a/packages/commonjs/test/fixtures/function/dynamic-require-absolute-paths/submodule.js b/packages/commonjs/test/fixtures/function/dynamic-require-absolute-paths/submodule.js deleted file mode 100755 index c285d34bc..000000000 --- a/packages/commonjs/test/fixtures/function/dynamic-require-absolute-paths/submodule.js +++ /dev/null @@ -1 +0,0 @@ -module.exports = 'submodule'; diff --git a/packages/commonjs/test/fixtures/function/dynamic-require-fallback/_config.js b/packages/commonjs/test/fixtures/function/dynamic-require-fallback/_config.js new file mode 100755 index 000000000..2e93c732b --- /dev/null +++ b/packages/commonjs/test/fixtures/function/dynamic-require-fallback/_config.js @@ -0,0 +1,6 @@ +module.exports = { + description: 'keeps a require call as fallback when configured', + pluginOptions: { + ignoreDynamicRequires: true + } +}; diff --git a/packages/commonjs/test/fixtures/function/dynamic-require-fallback/dep.js b/packages/commonjs/test/fixtures/function/dynamic-require-fallback/dep.js new file mode 100755 index 000000000..d0afb22c4 --- /dev/null +++ b/packages/commonjs/test/fixtures/function/dynamic-require-fallback/dep.js @@ -0,0 +1 @@ +module.exports = 'dep'; diff --git a/packages/commonjs/test/fixtures/function/dynamic-require-fallback/main.js b/packages/commonjs/test/fixtures/function/dynamic-require-fallback/main.js new file mode 100755 index 000000000..add49eec6 --- /dev/null +++ b/packages/commonjs/test/fixtures/function/dynamic-require-fallback/main.js @@ -0,0 +1,8 @@ +/* eslint-disable import/no-dynamic-require, global-require */ + +function takeModule(withName) { + return require(withName); +} + +// The bundled code will run from test/helpers/util.js +t.is(takeModule('../fixtures/function/dynamic-require-fallback/dep.js'), 'dep'); diff --git a/packages/commonjs/test/fixtures/function/dynamic-require-globs/main.js b/packages/commonjs/test/fixtures/function/dynamic-require-globs/main.js index 64e2c1e87..e1d9514d9 100755 --- a/packages/commonjs/test/fixtures/function/dynamic-require-globs/main.js +++ b/packages/commonjs/test/fixtures/function/dynamic-require-globs/main.js @@ -7,12 +7,7 @@ function takeModule(withName) { t.is(takeModule('submodule1.js'), 'submodule1'); t.is(takeModule('submodule2.js'), 'submodule2'); t.is(takeModule('extramodule1.js'), 'extramodule1'); - -let hasThrown = false; -try { - takeModule('extramodule2.js'); -} catch (error) { - t.truthy(/Cannot find module '\.\/extramodule2\.js'/.test(error.message)); - hasThrown = true; -} -t.truthy(hasThrown); +t.throws(() => takeModule('extramodule2.js'), { + message: + 'Could not dynamically require "./extramodule2.js". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.' +}); diff --git a/packages/commonjs/test/fixtures/function/dynamic-require-no-fallback/_config.js b/packages/commonjs/test/fixtures/function/dynamic-require-no-fallback/_config.js new file mode 100755 index 000000000..47ec76dd6 --- /dev/null +++ b/packages/commonjs/test/fixtures/function/dynamic-require-no-fallback/_config.js @@ -0,0 +1,3 @@ +module.exports = { + description: 'throws when there is no fallback for a dynamic require call' +}; diff --git a/packages/commonjs/test/fixtures/function/dynamic-require-no-fallback/main.js b/packages/commonjs/test/fixtures/function/dynamic-require-no-fallback/main.js new file mode 100755 index 000000000..31ec4917c --- /dev/null +++ b/packages/commonjs/test/fixtures/function/dynamic-require-no-fallback/main.js @@ -0,0 +1,10 @@ +/* eslint-disable import/no-dynamic-require, global-require */ + +function takeModule(withName) { + return require(withName); +} + +t.throws(() => takeModule('./dep.js'), { + message: + 'Could not dynamically require "./dep.js". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.' +}); diff --git a/packages/commonjs/test/fixtures/function/dynamic-require-targets-fallback/_config.js b/packages/commonjs/test/fixtures/function/dynamic-require-targets-fallback/_config.js new file mode 100755 index 000000000..6123cc654 --- /dev/null +++ b/packages/commonjs/test/fixtures/function/dynamic-require-targets-fallback/_config.js @@ -0,0 +1,7 @@ +module.exports = { + description: 'keeps a require call as fallback when configured for dynamicRequireTargets', + pluginOptions: { + ignoreDynamicRequires: true, + dynamicRequireTargets: ['fixtures/function/dynamic-require-targets-fallback/dep1.js'] + } +}; diff --git a/packages/commonjs/test/fixtures/function/dynamic-require-targets-fallback/dep1.js b/packages/commonjs/test/fixtures/function/dynamic-require-targets-fallback/dep1.js new file mode 100755 index 000000000..d0afb22c4 --- /dev/null +++ b/packages/commonjs/test/fixtures/function/dynamic-require-targets-fallback/dep1.js @@ -0,0 +1 @@ +module.exports = 'dep'; diff --git a/packages/commonjs/test/fixtures/function/dynamic-require-targets-fallback/dep2.js b/packages/commonjs/test/fixtures/function/dynamic-require-targets-fallback/dep2.js new file mode 100755 index 000000000..d0afb22c4 --- /dev/null +++ b/packages/commonjs/test/fixtures/function/dynamic-require-targets-fallback/dep2.js @@ -0,0 +1 @@ +module.exports = 'dep'; diff --git a/packages/commonjs/test/fixtures/function/dynamic-require-targets-fallback/main.js b/packages/commonjs/test/fixtures/function/dynamic-require-targets-fallback/main.js new file mode 100755 index 000000000..3652fbc73 --- /dev/null +++ b/packages/commonjs/test/fixtures/function/dynamic-require-targets-fallback/main.js @@ -0,0 +1,9 @@ +/* eslint-disable import/no-dynamic-require, global-require */ + +function takeModule(withName) { + return require(withName); +} + +t.is(takeModule('./dep1.js'), 'dep'); +// The bundled code will run from test/helpers/util.js +t.is(takeModule('../fixtures/function/dynamic-require-targets-fallback/dep2.js'), 'dep'); diff --git a/packages/commonjs/test/fixtures/function/dynamic-require-targets-no-fallback/_config.js b/packages/commonjs/test/fixtures/function/dynamic-require-targets-no-fallback/_config.js new file mode 100755 index 000000000..ff229d8f0 --- /dev/null +++ b/packages/commonjs/test/fixtures/function/dynamic-require-targets-no-fallback/_config.js @@ -0,0 +1,7 @@ +module.exports = { + description: + 'throws when there is no require call configured as fallback for dynamicRequireTargets', + pluginOptions: { + dynamicRequireTargets: ['fixtures/function/dynamic-require-targets-no-fallback/dep1.js'] + } +}; diff --git a/packages/commonjs/test/fixtures/function/dynamic-require-targets-no-fallback/dep1.js b/packages/commonjs/test/fixtures/function/dynamic-require-targets-no-fallback/dep1.js new file mode 100755 index 000000000..d0afb22c4 --- /dev/null +++ b/packages/commonjs/test/fixtures/function/dynamic-require-targets-no-fallback/dep1.js @@ -0,0 +1 @@ +module.exports = 'dep'; diff --git a/packages/commonjs/test/fixtures/function/dynamic-require-targets-no-fallback/main.js b/packages/commonjs/test/fixtures/function/dynamic-require-targets-no-fallback/main.js new file mode 100755 index 000000000..097c93f68 --- /dev/null +++ b/packages/commonjs/test/fixtures/function/dynamic-require-targets-no-fallback/main.js @@ -0,0 +1,11 @@ +/* eslint-disable import/no-dynamic-require, global-require */ + +function takeModule(withName) { + return require(withName); +} + +t.is(takeModule('./dep1.js'), 'dep'); +t.throws(() => takeModule('./dep2.js'), { + message: + 'Could not dynamically require "./dep2.js". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.' +}); diff --git a/packages/commonjs/test/fixtures/function/global-not-overwritten/encode.js b/packages/commonjs/test/fixtures/function/global-not-overwritten/encode.js index 47df37ebe..11ef1a2aa 100644 --- a/packages/commonjs/test/fixtures/function/global-not-overwritten/encode.js +++ b/packages/commonjs/test/fixtures/function/global-not-overwritten/encode.js @@ -1,4 +1,4 @@ -exports.encodeURIComponent = function() { +exports.encodeURIComponent = function () { return encodeURIComponent(this.str); }; diff --git a/packages/commonjs/test/fixtures/function/inline/main.js b/packages/commonjs/test/fixtures/function/inline/main.js index 9c89da3ac..06c18b41a 100644 --- a/packages/commonjs/test/fixtures/function/inline/main.js +++ b/packages/commonjs/test/fixtures/function/inline/main.js @@ -1,4 +1,4 @@ /* eslint-disable global-require */ -module.exports = function() { +module.exports = function () { return require('./multiply')(2, require('./foo')); }; diff --git a/packages/commonjs/test/fixtures/function/inline/multiply.js b/packages/commonjs/test/fixtures/function/inline/multiply.js index 1d31f4c02..b5a6c5bea 100644 --- a/packages/commonjs/test/fixtures/function/inline/multiply.js +++ b/packages/commonjs/test/fixtures/function/inline/multiply.js @@ -1,3 +1,3 @@ -module.exports = function(a, b) { +module.exports = function (a, b) { return a * b; }; diff --git a/packages/commonjs/test/fixtures/function/toplevel-return-complex/bar.js b/packages/commonjs/test/fixtures/function/toplevel-return-complex/bar.js index 6c780a1b8..9d12d7de1 100644 --- a/packages/commonjs/test/fixtures/function/toplevel-return-complex/bar.js +++ b/packages/commonjs/test/fixtures/function/toplevel-return-complex/bar.js @@ -1,3 +1,3 @@ -module.exports = function() { +module.exports = function () { return true; }; diff --git a/packages/commonjs/test/fixtures/function/unsupported-dynamic-require/_config.js b/packages/commonjs/test/fixtures/function/unsupported-dynamic-require/_config.js deleted file mode 100755 index b77e73bbf..000000000 --- a/packages/commonjs/test/fixtures/function/unsupported-dynamic-require/_config.js +++ /dev/null @@ -1,3 +0,0 @@ -module.exports = { - description: 'throws for unsupported dynamic require calls' -}; diff --git a/packages/commonjs/test/fixtures/function/unsupported-dynamic-require/main.js b/packages/commonjs/test/fixtures/function/unsupported-dynamic-require/main.js deleted file mode 100755 index 802f83fc6..000000000 --- a/packages/commonjs/test/fixtures/function/unsupported-dynamic-require/main.js +++ /dev/null @@ -1,10 +0,0 @@ -/* eslint-disable import/no-dynamic-require, global-require */ - -t.throws(() => require(getRequireTarget()), { - message: - 'Could not dynamically require "foo-bar". Please configure the dynamicRequireTargets option of @rollup/plugin-commonjs appropriately for this require call to behave properly.' -}); - -function getRequireTarget() { - return 'foo-bar'; -} diff --git a/packages/commonjs/test/fixtures/samples/dynamic-require-different-loader/submodule2.js b/packages/commonjs/test/fixtures/samples/dynamic-require-different-loader/submodule2.js index f470282a9..28a021e39 100755 --- a/packages/commonjs/test/fixtures/samples/dynamic-require-different-loader/submodule2.js +++ b/packages/commonjs/test/fixtures/samples/dynamic-require-different-loader/submodule2.js @@ -1,3 +1,3 @@ -module.exports = function() { +module.exports = function () { return 'Hello there'; }; diff --git a/packages/commonjs/test/fixtures/samples/umd/correct-scoping.js b/packages/commonjs/test/fixtures/samples/umd/correct-scoping.js index a4816cf64..c1008ba9d 100644 --- a/packages/commonjs/test/fixtures/samples/umd/correct-scoping.js +++ b/packages/commonjs/test/fixtures/samples/umd/correct-scoping.js @@ -1,5 +1,5 @@ if (typeof require === 'function') { - module.exports = (function(require) { + module.exports = (function (require) { return typeof require; })({}); } diff --git a/packages/commonjs/test/form.js b/packages/commonjs/test/form.js index 656e92fa2..ae245863a 100644 --- a/packages/commonjs/test/form.js +++ b/packages/commonjs/test/form.js @@ -74,8 +74,15 @@ readdirSync('./fixtures/form').forEach((dir) => { // this will benefit issues like `form/try-catch-remove` where whitespace is left in the line, // and testing on windows (\r\n) t.is( - actual.split('\n').map(x => x.trimEnd()).join('\n'), - expected.split('\n').map(x => x.trimEnd()).join('\n')); + actual + .split('\n') + .map((x) => x.trimEnd()) + .join('\n'), + expected + .split('\n') + .map((x) => x.trimEnd()) + .join('\n') + ); } }); }); diff --git a/packages/commonjs/test/snapshots/function.js.md b/packages/commonjs/test/snapshots/function.js.md index 1717deded..dd86c2686 100644 --- a/packages/commonjs/test/snapshots/function.js.md +++ b/packages/commonjs/test/snapshots/function.js.md @@ -423,7 +423,7 @@ Generated by [AVA](https://avajs.dev). cachedModule.loaded = true;␊ return cachedModule.exports;␊ } }␊ - return require(path);␊ + throw new Error('Could not dynamically require "' + path + '". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.');␊ }␊ ␊ commonjsRequire.cache = DYNAMIC_REQUIRE_CACHE;␊ @@ -626,7 +626,7 @@ Generated by [AVA](https://avajs.dev). cachedModule.loaded = true;␊ return cachedModule.exports;␊ } }␊ - return require(path);␊ + throw new Error('Could not dynamically require "' + path + '". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.');␊ }␊ ␊ commonjsRequire.cache = DYNAMIC_REQUIRE_CACHE;␊ @@ -831,7 +831,7 @@ Generated by [AVA](https://avajs.dev). cachedModule.loaded = true;␊ return cachedModule.exports;␊ } }␊ - return require(path);␊ + throw new Error('Could not dynamically require "' + path + '". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.');␊ }␊ ␊ commonjsRequire.cache = DYNAMIC_REQUIRE_CACHE;␊ @@ -884,206 +884,6 @@ Generated by [AVA](https://avajs.dev). `, } -## dynamic-require-absolute-paths - -> Snapshot 1 - - { - 'main.js': `'use strict';␊ - ␊ - var Path = require('path');␊ - ␊ - function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }␊ - ␊ - var Path__default = /*#__PURE__*/_interopDefaultLegacy(Path);␊ - ␊ - var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};␊ - ␊ - function commonjsRegister (path, loader) {␊ - DYNAMIC_REQUIRE_LOADERS[path] = loader;␊ - }␊ - ␊ - const DYNAMIC_REQUIRE_LOADERS = Object.create(null);␊ - const DYNAMIC_REQUIRE_CACHE = Object.create(null);␊ - const DEFAULT_PARENT_MODULE = {␊ - id: '<' + 'rollup>', exports: {}, parent: undefined, filename: null, loaded: false, children: [], paths: []␊ - };␊ - const CHECKED_EXTENSIONS = ['', '.js', '.json'];␊ - ␊ - function normalize (path) {␊ - path = path.replace(/\\\\/g, '/');␊ - const parts = path.split('/');␊ - const slashed = parts[0] === '';␊ - for (let i = 1; i < parts.length; i++) {␊ - if (parts[i] === '.' || parts[i] === '') {␊ - parts.splice(i--, 1);␊ - }␊ - }␊ - for (let i = 1; i < parts.length; i++) {␊ - if (parts[i] !== '..') continue;␊ - if (i > 0 && parts[i - 1] !== '..' && parts[i - 1] !== '.') {␊ - parts.splice(--i, 2);␊ - i--;␊ - }␊ - }␊ - path = parts.join('/');␊ - if (slashed && path[0] !== '/')␊ - path = '/' + path;␊ - else if (path.length === 0)␊ - path = '.';␊ - return path;␊ - }␊ - ␊ - function join () {␊ - if (arguments.length === 0)␊ - return '.';␊ - let joined;␊ - for (let i = 0; i < arguments.length; ++i) {␊ - let arg = arguments[i];␊ - if (arg.length > 0) {␊ - if (joined === undefined)␊ - joined = arg;␊ - else␊ - joined += '/' + arg;␊ - }␊ - }␊ - if (joined === undefined)␊ - return '.';␊ - ␊ - return joined;␊ - }␊ - ␊ - function isPossibleNodeModulesPath (modulePath) {␊ - let c0 = modulePath[0];␊ - if (c0 === '/' || c0 === '\\\\') return false;␊ - let c1 = modulePath[1], c2 = modulePath[2];␊ - if ((c0 === '.' && (!c1 || c1 === '/' || c1 === '\\\\')) ||␊ - (c0 === '.' && c1 === '.' && (!c2 || c2 === '/' || c2 === '\\\\'))) return false;␊ - if (c1 === ':' && (c2 === '/' || c2 === '\\\\'))␊ - return false;␊ - return true;␊ - }␊ - ␊ - function dirname (path) {␊ - if (path.length === 0)␊ - return '.';␊ - ␊ - let i = path.length - 1;␊ - while (i > 0) {␊ - const c = path.charCodeAt(i);␊ - if ((c === 47 || c === 92) && i !== path.length - 1)␊ - break;␊ - i--;␊ - }␊ - ␊ - if (i > 0)␊ - return path.substr(0, i);␊ - ␊ - if (path.chartCodeAt(0) === 47 || path.chartCodeAt(0) === 92)␊ - return path.charAt(0);␊ - ␊ - return '.';␊ - }␊ - ␊ - function commonjsResolveImpl (path, originalModuleDir, testCache) {␊ - const shouldTryNodeModules = isPossibleNodeModulesPath(path);␊ - path = normalize(path);␊ - let relPath;␊ - if (path[0] === '/') {␊ - originalModuleDir = '/';␊ - }␊ - while (true) {␊ - if (!shouldTryNodeModules) {␊ - relPath = originalModuleDir ? normalize(originalModuleDir + '/' + path) : path;␊ - } else if (originalModuleDir) {␊ - relPath = normalize(originalModuleDir + '/node_modules/' + path);␊ - } else {␊ - relPath = normalize(join('node_modules', path));␊ - }␊ - ␊ - if (relPath.endsWith('/..')) {␊ - break; // Travelled too far up, avoid infinite loop␊ - }␊ - ␊ - for (let extensionIndex = 0; extensionIndex < CHECKED_EXTENSIONS.length; extensionIndex++) {␊ - const resolvedPath = relPath + CHECKED_EXTENSIONS[extensionIndex];␊ - if (DYNAMIC_REQUIRE_CACHE[resolvedPath]) {␊ - return resolvedPath;␊ - } if (DYNAMIC_REQUIRE_LOADERS[resolvedPath]) {␊ - return resolvedPath;␊ - } }␊ - if (!shouldTryNodeModules) break;␊ - const nextDir = normalize(originalModuleDir + '/..');␊ - if (nextDir === originalModuleDir) break;␊ - originalModuleDir = nextDir;␊ - }␊ - return null;␊ - }␊ - ␊ - function commonjsResolve (path, originalModuleDir) {␊ - const resolvedPath = commonjsResolveImpl(path, originalModuleDir);␊ - if (resolvedPath !== null) {␊ - return resolvedPath;␊ - }␊ - return require.resolve(path);␊ - }␊ - ␊ - function commonjsRequire (path, originalModuleDir) {␊ - const resolvedPath = commonjsResolveImpl(path, originalModuleDir);␊ - if (resolvedPath !== null) {␊ - let cachedModule = DYNAMIC_REQUIRE_CACHE[resolvedPath];␊ - if (cachedModule) return cachedModule.exports;␊ - const loader = DYNAMIC_REQUIRE_LOADERS[resolvedPath];␊ - if (loader) {␊ - DYNAMIC_REQUIRE_CACHE[resolvedPath] = cachedModule = {␊ - id: resolvedPath,␊ - filename: resolvedPath,␊ - path: dirname(resolvedPath),␊ - exports: {},␊ - parent: DEFAULT_PARENT_MODULE,␊ - loaded: false,␊ - children: [],␊ - paths: [],␊ - require: function (path, base) {␊ - return commonjsRequire(path, (base === undefined || base === null) ? cachedModule.path : base);␊ - }␊ - };␊ - try {␊ - loader.call(commonjsGlobal, cachedModule, cachedModule.exports);␊ - } catch (error) {␊ - delete DYNAMIC_REQUIRE_CACHE[resolvedPath];␊ - throw error;␊ - }␊ - cachedModule.loaded = true;␊ - return cachedModule.exports;␊ - } }␊ - return require(path);␊ - }␊ - ␊ - commonjsRequire.cache = DYNAMIC_REQUIRE_CACHE;␊ - commonjsRequire.resolve = commonjsResolve;␊ - ␊ - commonjsRegister("/$$rollup_base$$/fixtures/function/dynamic-require-absolute-paths/submodule.js", function (module, exports) {␊ - module.exports = 'submodule';␊ - ␊ - });␊ - ␊ - /* eslint-disable import/no-dynamic-require, global-require */␊ - ␊ - ␊ - ␊ - const basePath = `${process.cwd()}/fixtures/function/dynamic-require-absolute-paths`;␊ - ␊ - t.is(commonjsRequire(Path__default['default'].resolve(`${basePath}/submodule.js`),"/$$rollup_base$$/fixtures/function/dynamic-require-absolute-paths"), 'submodule');␊ - ␊ - var main = {␊ - ␊ - };␊ - ␊ - module.exports = main;␊ - `, - } - ## dynamic-require-cache-reference > Snapshot 1 @@ -1251,7 +1051,7 @@ Generated by [AVA](https://avajs.dev). cachedModule.loaded = true;␊ return cachedModule.exports;␊ } }␊ - return require(path);␊ + throw new Error('Could not dynamically require "' + path + '". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.');␊ }␊ ␊ commonjsRequire.cache = DYNAMIC_REQUIRE_CACHE;␊ @@ -1327,7 +1127,7 @@ Generated by [AVA](https://avajs.dev). > Snapshot 1 { - 'lib2-4ae05749.js': `'use strict';␊ + 'lib2-8f3d0aad.js': `'use strict';␊ ␊ var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};␊ ␊ @@ -1489,7 +1289,7 @@ Generated by [AVA](https://avajs.dev). cachedModule.loaded = true;␊ return cachedModule.exports;␊ } }␊ - return require(path);␊ + throw new Error('Could not dynamically require "' + path + '". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.');␊ }␊ ␊ commonjsRequire.cache = DYNAMIC_REQUIRE_CACHE;␊ @@ -1522,7 +1322,7 @@ Generated by [AVA](https://avajs.dev). `, 'main.js': `'use strict';␊ ␊ - var lib2 = require('./lib2-4ae05749.js');␊ + var lib2 = require('./lib2-8f3d0aad.js');␊ ␊ /* eslint-disable import/no-dynamic-require, global-require */␊ ␊ @@ -1539,7 +1339,7 @@ Generated by [AVA](https://avajs.dev). `, 'main2.js': `'use strict';␊ ␊ - require('./lib2-4ae05749.js');␊ + require('./lib2-8f3d0aad.js');␊ ␊ `, } @@ -1711,7 +1511,7 @@ Generated by [AVA](https://avajs.dev). cachedModule.loaded = true;␊ return cachedModule.exports;␊ } }␊ - return require(path);␊ + throw new Error('Could not dynamically require "' + path + '". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.');␊ }␊ ␊ commonjsRequire.cache = DYNAMIC_REQUIRE_CACHE;␊ @@ -1901,7 +1701,7 @@ Generated by [AVA](https://avajs.dev). cachedModule.loaded = true;␊ return cachedModule.exports;␊ } }␊ - return require(path);␊ + throw new Error('Could not dynamically require "' + path + '". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.');␊ }␊ ␊ commonjsRequire.cache = DYNAMIC_REQUIRE_CACHE;␊ @@ -1936,6 +1736,30 @@ Generated by [AVA](https://avajs.dev). `, } +## dynamic-require-fallback + +> Snapshot 1 + + { + 'main.js': `'use strict';␊ + ␊ + /* eslint-disable import/no-dynamic-require, global-require */␊ + ␊ + function takeModule(withName) {␊ + return require(withName);␊ + }␊ + ␊ + // The bundled code will run from test/helpers/util.js␊ + t.is(takeModule('../fixtures/function/dynamic-require-fallback/dep.js'), 'dep');␊ + ␊ + var main = {␊ + ␊ + };␊ + ␊ + module.exports = main;␊ + `, + } + ## dynamic-require-from-es-import > Snapshot 1 @@ -2103,7 +1927,7 @@ Generated by [AVA](https://avajs.dev). cachedModule.loaded = true;␊ return cachedModule.exports;␊ } }␊ - return require(path);␊ + throw new Error('Could not dynamically require "' + path + '". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.');␊ }␊ ␊ commonjsRequire.cache = DYNAMIC_REQUIRE_CACHE;␊ @@ -2287,7 +2111,7 @@ Generated by [AVA](https://avajs.dev). cachedModule.loaded = true;␊ return cachedModule.exports;␊ } }␊ - return require(path);␊ + throw new Error('Could not dynamically require "' + path + '". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.');␊ }␊ ␊ commonjsRequire.cache = DYNAMIC_REQUIRE_CACHE;␊ @@ -2317,15 +2141,10 @@ Generated by [AVA](https://avajs.dev). t.is(takeModule('submodule1.js'), 'submodule1');␊ t.is(takeModule('submodule2.js'), 'submodule2');␊ t.is(takeModule('extramodule1.js'), 'extramodule1');␊ - ␊ - let hasThrown = false;␊ - try {␊ - takeModule('extramodule2.js');␊ - } catch (error) {␊ - t.truthy(/Cannot find module '\\.\\/extramodule2\\.js'/.test(error.message));␊ - hasThrown = true;␊ - }␊ - t.truthy(hasThrown);␊ + t.throws(() => takeModule('extramodule2.js'), {␊ + message:␊ + 'Could not dynamically require "./extramodule2.js". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.'␊ + });␊ ␊ var main = {␊ ␊ @@ -2502,7 +2321,7 @@ Generated by [AVA](https://avajs.dev). cachedModule.loaded = true;␊ return cachedModule.exports;␊ } }␊ - return require(path);␊ + throw new Error('Could not dynamically require "' + path + '". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.');␊ }␊ ␊ commonjsRequire.cache = DYNAMIC_REQUIRE_CACHE;␊ @@ -2714,7 +2533,7 @@ Generated by [AVA](https://avajs.dev). cachedModule.loaded = true;␊ return cachedModule.exports;␊ } }␊ - return require(path);␊ + throw new Error('Could not dynamically require "' + path + '". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.');␊ }␊ ␊ commonjsRequire.cache = DYNAMIC_REQUIRE_CACHE;␊ @@ -2731,22 +2550,485 @@ Generated by [AVA](https://avajs.dev). ␊ /* eslint-disable import/no-dynamic-require, global-require */␊ ␊ - function takeModule(withName) {␊ - return commonjsRequire(`./${withName}`,"/$$rollup_base$$/fixtures/function/dynamic-require-json");␊ - }␊ + function takeModule(withName) {␊ + return commonjsRequire(`./${withName}`,"/$$rollup_base$$/fixtures/function/dynamic-require-json");␊ + }␊ + ␊ + t.deepEqual(takeModule('dynamic.json'), { value: 'present' });␊ + t.deepEqual(takeModule('dynamic'), { value: 'present' });␊ + ␊ + var main = {␊ + ␊ + };␊ + ␊ + module.exports = main;␊ + `, + } + +## dynamic-require-no-fallback + +> Snapshot 1 + + { + 'main.js': `'use strict';␊ + ␊ + function commonjsRequire (path) {␊ + throw new Error('Could not dynamically require "' + path + '". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.');␊ + }␊ + ␊ + /* eslint-disable import/no-dynamic-require, global-require */␊ + ␊ + function takeModule(withName) {␊ + return commonjsRequire(withName);␊ + }␊ + ␊ + t.throws(() => takeModule('./dep.js'), {␊ + message:␊ + 'Could not dynamically require "./dep.js". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.'␊ + });␊ + ␊ + var main = {␊ + ␊ + };␊ + ␊ + module.exports = main;␊ + `, + } + +## dynamic-require-package + +> Snapshot 1 + + { + 'main.js': `'use strict';␊ + ␊ + var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};␊ + ␊ + function commonjsRegister (path, loader) {␊ + DYNAMIC_REQUIRE_LOADERS[path] = loader;␊ + }␊ + ␊ + const DYNAMIC_REQUIRE_LOADERS = Object.create(null);␊ + const DYNAMIC_REQUIRE_CACHE = Object.create(null);␊ + const DEFAULT_PARENT_MODULE = {␊ + id: '<' + 'rollup>', exports: {}, parent: undefined, filename: null, loaded: false, children: [], paths: []␊ + };␊ + const CHECKED_EXTENSIONS = ['', '.js', '.json'];␊ + ␊ + function normalize (path) {␊ + path = path.replace(/\\\\/g, '/');␊ + const parts = path.split('/');␊ + const slashed = parts[0] === '';␊ + for (let i = 1; i < parts.length; i++) {␊ + if (parts[i] === '.' || parts[i] === '') {␊ + parts.splice(i--, 1);␊ + }␊ + }␊ + for (let i = 1; i < parts.length; i++) {␊ + if (parts[i] !== '..') continue;␊ + if (i > 0 && parts[i - 1] !== '..' && parts[i - 1] !== '.') {␊ + parts.splice(--i, 2);␊ + i--;␊ + }␊ + }␊ + path = parts.join('/');␊ + if (slashed && path[0] !== '/')␊ + path = '/' + path;␊ + else if (path.length === 0)␊ + path = '.';␊ + return path;␊ + }␊ + ␊ + function join () {␊ + if (arguments.length === 0)␊ + return '.';␊ + let joined;␊ + for (let i = 0; i < arguments.length; ++i) {␊ + let arg = arguments[i];␊ + if (arg.length > 0) {␊ + if (joined === undefined)␊ + joined = arg;␊ + else␊ + joined += '/' + arg;␊ + }␊ + }␊ + if (joined === undefined)␊ + return '.';␊ + ␊ + return joined;␊ + }␊ + ␊ + function isPossibleNodeModulesPath (modulePath) {␊ + let c0 = modulePath[0];␊ + if (c0 === '/' || c0 === '\\\\') return false;␊ + let c1 = modulePath[1], c2 = modulePath[2];␊ + if ((c0 === '.' && (!c1 || c1 === '/' || c1 === '\\\\')) ||␊ + (c0 === '.' && c1 === '.' && (!c2 || c2 === '/' || c2 === '\\\\'))) return false;␊ + if (c1 === ':' && (c2 === '/' || c2 === '\\\\'))␊ + return false;␊ + return true;␊ + }␊ + ␊ + function dirname (path) {␊ + if (path.length === 0)␊ + return '.';␊ + ␊ + let i = path.length - 1;␊ + while (i > 0) {␊ + const c = path.charCodeAt(i);␊ + if ((c === 47 || c === 92) && i !== path.length - 1)␊ + break;␊ + i--;␊ + }␊ + ␊ + if (i > 0)␊ + return path.substr(0, i);␊ + ␊ + if (path.chartCodeAt(0) === 47 || path.chartCodeAt(0) === 92)␊ + return path.charAt(0);␊ + ␊ + return '.';␊ + }␊ + ␊ + function commonjsResolveImpl (path, originalModuleDir, testCache) {␊ + const shouldTryNodeModules = isPossibleNodeModulesPath(path);␊ + path = normalize(path);␊ + let relPath;␊ + if (path[0] === '/') {␊ + originalModuleDir = '/';␊ + }␊ + while (true) {␊ + if (!shouldTryNodeModules) {␊ + relPath = originalModuleDir ? normalize(originalModuleDir + '/' + path) : path;␊ + } else if (originalModuleDir) {␊ + relPath = normalize(originalModuleDir + '/node_modules/' + path);␊ + } else {␊ + relPath = normalize(join('node_modules', path));␊ + }␊ + ␊ + if (relPath.endsWith('/..')) {␊ + break; // Travelled too far up, avoid infinite loop␊ + }␊ + ␊ + for (let extensionIndex = 0; extensionIndex < CHECKED_EXTENSIONS.length; extensionIndex++) {␊ + const resolvedPath = relPath + CHECKED_EXTENSIONS[extensionIndex];␊ + if (DYNAMIC_REQUIRE_CACHE[resolvedPath]) {␊ + return resolvedPath;␊ + } if (DYNAMIC_REQUIRE_LOADERS[resolvedPath]) {␊ + return resolvedPath;␊ + } }␊ + if (!shouldTryNodeModules) break;␊ + const nextDir = normalize(originalModuleDir + '/..');␊ + if (nextDir === originalModuleDir) break;␊ + originalModuleDir = nextDir;␊ + }␊ + return null;␊ + }␊ + ␊ + function commonjsResolve (path, originalModuleDir) {␊ + const resolvedPath = commonjsResolveImpl(path, originalModuleDir);␊ + if (resolvedPath !== null) {␊ + return resolvedPath;␊ + }␊ + return require.resolve(path);␊ + }␊ + ␊ + function commonjsRequire (path, originalModuleDir) {␊ + const resolvedPath = commonjsResolveImpl(path, originalModuleDir);␊ + if (resolvedPath !== null) {␊ + let cachedModule = DYNAMIC_REQUIRE_CACHE[resolvedPath];␊ + if (cachedModule) return cachedModule.exports;␊ + const loader = DYNAMIC_REQUIRE_LOADERS[resolvedPath];␊ + if (loader) {␊ + DYNAMIC_REQUIRE_CACHE[resolvedPath] = cachedModule = {␊ + id: resolvedPath,␊ + filename: resolvedPath,␊ + path: dirname(resolvedPath),␊ + exports: {},␊ + parent: DEFAULT_PARENT_MODULE,␊ + loaded: false,␊ + children: [],␊ + paths: [],␊ + require: function (path, base) {␊ + return commonjsRequire(path, (base === undefined || base === null) ? cachedModule.path : base);␊ + }␊ + };␊ + try {␊ + loader.call(commonjsGlobal, cachedModule, cachedModule.exports);␊ + } catch (error) {␊ + delete DYNAMIC_REQUIRE_CACHE[resolvedPath];␊ + throw error;␊ + }␊ + cachedModule.loaded = true;␊ + return cachedModule.exports;␊ + } }␊ + throw new Error('Could not dynamically require "' + path + '". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.');␊ + }␊ + ␊ + commonjsRequire.cache = DYNAMIC_REQUIRE_CACHE;␊ + commonjsRequire.resolve = commonjsResolve;␊ + ␊ + commonjsRegister("/$$rollup_base$$/fixtures/function/dynamic-require-package/entry.js", function (module, exports) {␊ + module.exports = 'same-directory';␊ + ␊ + });␊ + ␊ + commonjsRegister("/$$rollup_base$$/fixtures/function/dynamic-require-package/sub/entry.js", function (module, exports) {␊ + module.exports = 'sub';␊ + ␊ + });␊ + ␊ + commonjsRegister("/$$rollup_base$$/fixtures/function/dynamic-require-package/node_modules/custom-module/entry.js", function (module, exports) {␊ + module.exports = 'custom-module';␊ + ␊ + });␊ + ␊ + commonjsRegister("/$$rollup_base$$/fixtures/function/dynamic-require-package", function (module, exports) {␊ + module.exports = commonjsRequire("/$$rollup_base$$/fixtures/function/dynamic-require-package/entry.js", null);␊ + });␊ + commonjsRegister("/$$rollup_base$$/fixtures/function/dynamic-require-package/sub", function (module, exports) {␊ + module.exports = commonjsRequire("/$$rollup_base$$/fixtures/function/dynamic-require-package/sub/entry.js", null);␊ + });␊ + commonjsRegister("/$$rollup_base$$/fixtures/function/dynamic-require-package/node_modules/custom-module", function (module, exports) {␊ + module.exports = commonjsRequire("/$$rollup_base$$/fixtures/function/dynamic-require-package/node_modules/custom-module/entry.js", null);␊ + });␊ + ␊ + /* eslint-disable import/no-dynamic-require, global-require */␊ + ␊ + function takeModule(name) {␊ + return commonjsRequire(name,"/$$rollup_base$$/fixtures/function/dynamic-require-package/sub");␊ + }␊ + ␊ + var sub = {␊ + parent: takeModule('..'),␊ + customModule: takeModule('custom-module')␊ + };␊ + ␊ + /* eslint-disable import/no-dynamic-require, global-require */␊ + ␊ + function takeModule$1(name) {␊ + return commonjsRequire(name,"/$$rollup_base$$/fixtures/function/dynamic-require-package");␊ + }␊ + ␊ + t.is(takeModule$1('.'), 'same-directory');␊ + t.is(takeModule$1('./'), 'same-directory');␊ + t.is(takeModule$1('.//'), 'same-directory');␊ + ␊ + t.is(takeModule$1('./sub'), 'sub');␊ + ␊ + t.is(takeModule$1('custom-module'), 'custom-module');␊ + t.deepEqual(sub, { parent: 'same-directory', customModule: 'custom-module' });␊ + ␊ + var main = {␊ + ␊ + };␊ + ␊ + module.exports = main;␊ + `, + } + +## dynamic-require-package-sub + +> Snapshot 1 + + { + 'entry.js': `'use strict';␊ + ␊ + var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};␊ + ␊ + function commonjsRegister (path, loader) {␊ + DYNAMIC_REQUIRE_LOADERS[path] = loader;␊ + }␊ + ␊ + const DYNAMIC_REQUIRE_LOADERS = Object.create(null);␊ + const DYNAMIC_REQUIRE_CACHE = Object.create(null);␊ + const DEFAULT_PARENT_MODULE = {␊ + id: '<' + 'rollup>', exports: {}, parent: undefined, filename: null, loaded: false, children: [], paths: []␊ + };␊ + const CHECKED_EXTENSIONS = ['', '.js', '.json'];␊ + ␊ + function normalize (path) {␊ + path = path.replace(/\\\\/g, '/');␊ + const parts = path.split('/');␊ + const slashed = parts[0] === '';␊ + for (let i = 1; i < parts.length; i++) {␊ + if (parts[i] === '.' || parts[i] === '') {␊ + parts.splice(i--, 1);␊ + }␊ + }␊ + for (let i = 1; i < parts.length; i++) {␊ + if (parts[i] !== '..') continue;␊ + if (i > 0 && parts[i - 1] !== '..' && parts[i - 1] !== '.') {␊ + parts.splice(--i, 2);␊ + i--;␊ + }␊ + }␊ + path = parts.join('/');␊ + if (slashed && path[0] !== '/')␊ + path = '/' + path;␊ + else if (path.length === 0)␊ + path = '.';␊ + return path;␊ + }␊ + ␊ + function join () {␊ + if (arguments.length === 0)␊ + return '.';␊ + let joined;␊ + for (let i = 0; i < arguments.length; ++i) {␊ + let arg = arguments[i];␊ + if (arg.length > 0) {␊ + if (joined === undefined)␊ + joined = arg;␊ + else␊ + joined += '/' + arg;␊ + }␊ + }␊ + if (joined === undefined)␊ + return '.';␊ + ␊ + return joined;␊ + }␊ + ␊ + function isPossibleNodeModulesPath (modulePath) {␊ + let c0 = modulePath[0];␊ + if (c0 === '/' || c0 === '\\\\') return false;␊ + let c1 = modulePath[1], c2 = modulePath[2];␊ + if ((c0 === '.' && (!c1 || c1 === '/' || c1 === '\\\\')) ||␊ + (c0 === '.' && c1 === '.' && (!c2 || c2 === '/' || c2 === '\\\\'))) return false;␊ + if (c1 === ':' && (c2 === '/' || c2 === '\\\\'))␊ + return false;␊ + return true;␊ + }␊ + ␊ + function dirname (path) {␊ + if (path.length === 0)␊ + return '.';␊ + ␊ + let i = path.length - 1;␊ + while (i > 0) {␊ + const c = path.charCodeAt(i);␊ + if ((c === 47 || c === 92) && i !== path.length - 1)␊ + break;␊ + i--;␊ + }␊ + ␊ + if (i > 0)␊ + return path.substr(0, i);␊ + ␊ + if (path.chartCodeAt(0) === 47 || path.chartCodeAt(0) === 92)␊ + return path.charAt(0);␊ + ␊ + return '.';␊ + }␊ + ␊ + function commonjsResolveImpl (path, originalModuleDir, testCache) {␊ + const shouldTryNodeModules = isPossibleNodeModulesPath(path);␊ + path = normalize(path);␊ + let relPath;␊ + if (path[0] === '/') {␊ + originalModuleDir = '/';␊ + }␊ + while (true) {␊ + if (!shouldTryNodeModules) {␊ + relPath = originalModuleDir ? normalize(originalModuleDir + '/' + path) : path;␊ + } else if (originalModuleDir) {␊ + relPath = normalize(originalModuleDir + '/node_modules/' + path);␊ + } else {␊ + relPath = normalize(join('node_modules', path));␊ + }␊ + ␊ + if (relPath.endsWith('/..')) {␊ + break; // Travelled too far up, avoid infinite loop␊ + }␊ + ␊ + for (let extensionIndex = 0; extensionIndex < CHECKED_EXTENSIONS.length; extensionIndex++) {␊ + const resolvedPath = relPath + CHECKED_EXTENSIONS[extensionIndex];␊ + if (DYNAMIC_REQUIRE_CACHE[resolvedPath]) {␊ + return resolvedPath;␊ + } if (DYNAMIC_REQUIRE_LOADERS[resolvedPath]) {␊ + return resolvedPath;␊ + } }␊ + if (!shouldTryNodeModules) break;␊ + const nextDir = normalize(originalModuleDir + '/..');␊ + if (nextDir === originalModuleDir) break;␊ + originalModuleDir = nextDir;␊ + }␊ + return null;␊ + }␊ + ␊ + function commonjsResolve (path, originalModuleDir) {␊ + const resolvedPath = commonjsResolveImpl(path, originalModuleDir);␊ + if (resolvedPath !== null) {␊ + return resolvedPath;␊ + }␊ + return require.resolve(path);␊ + }␊ + ␊ + function commonjsRequire (path, originalModuleDir) {␊ + const resolvedPath = commonjsResolveImpl(path, originalModuleDir);␊ + if (resolvedPath !== null) {␊ + let cachedModule = DYNAMIC_REQUIRE_CACHE[resolvedPath];␊ + if (cachedModule) return cachedModule.exports;␊ + const loader = DYNAMIC_REQUIRE_LOADERS[resolvedPath];␊ + if (loader) {␊ + DYNAMIC_REQUIRE_CACHE[resolvedPath] = cachedModule = {␊ + id: resolvedPath,␊ + filename: resolvedPath,␊ + path: dirname(resolvedPath),␊ + exports: {},␊ + parent: DEFAULT_PARENT_MODULE,␊ + loaded: false,␊ + children: [],␊ + paths: [],␊ + require: function (path, base) {␊ + return commonjsRequire(path, (base === undefined || base === null) ? cachedModule.path : base);␊ + }␊ + };␊ + try {␊ + loader.call(commonjsGlobal, cachedModule, cachedModule.exports);␊ + } catch (error) {␊ + delete DYNAMIC_REQUIRE_CACHE[resolvedPath];␊ + throw error;␊ + }␊ + cachedModule.loaded = true;␊ + return cachedModule.exports;␊ + } }␊ + throw new Error('Could not dynamically require "' + path + '". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.');␊ + }␊ + ␊ + commonjsRequire.cache = DYNAMIC_REQUIRE_CACHE;␊ + commonjsRequire.resolve = commonjsResolve;␊ + ␊ + commonjsRegister("/$$rollup_base$$/fixtures/function/dynamic-require-package-sub/node_modules/custom-module/entry.js", function (module, exports) {␊ + module.exports = 'custom-module';␊ + ␊ + });␊ + ␊ + var main = "./entry.js";␊ + var require$$0 = {␊ + main: main␊ + };␊ + ␊ + commonjsRegister("/$$rollup_base$$/fixtures/function/dynamic-require-package-sub/node_modules/custom-module/package.json", function (module, exports) {␊ + module.exports = require$$0;␊ + });␊ + ␊ + commonjsRegister("/$$rollup_base$$/fixtures/function/dynamic-require-package-sub/node_modules/custom-module", function (module, exports) {␊ + module.exports = commonjsRequire("/$$rollup_base$$/fixtures/function/dynamic-require-package-sub/node_modules/custom-module/entry.js", null);␊ + });␊ ␊ - t.deepEqual(takeModule('dynamic.json'), { value: 'present' });␊ - t.deepEqual(takeModule('dynamic'), { value: 'present' });␊ + t.is(commonjsRequire("custom-module", "/$$rollup_base$$/fixtures/function/dynamic-require-package-sub/sub"), 'custom-module');␊ ␊ - var main = {␊ + var entry = {␊ ␊ };␊ ␊ - module.exports = main;␊ + module.exports = entry;␊ `, } -## dynamic-require-package +## dynamic-require-relative-paths > Snapshot 1 @@ -2913,62 +3195,32 @@ Generated by [AVA](https://avajs.dev). cachedModule.loaded = true;␊ return cachedModule.exports;␊ } }␊ - return require(path);␊ + throw new Error('Could not dynamically require "' + path + '". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.');␊ }␊ ␊ commonjsRequire.cache = DYNAMIC_REQUIRE_CACHE;␊ commonjsRequire.resolve = commonjsResolve;␊ ␊ - commonjsRegister("/$$rollup_base$$/fixtures/function/dynamic-require-package/entry.js", function (module, exports) {␊ - module.exports = 'same-directory';␊ - ␊ - });␊ - ␊ - commonjsRegister("/$$rollup_base$$/fixtures/function/dynamic-require-package/sub/entry.js", function (module, exports) {␊ - module.exports = 'sub';␊ + commonjsRegister("/$$rollup_base$$/fixtures/function/dynamic-require-relative-paths/sub/submodule.js", function (module, exports) {␊ + module.exports = 'submodule';␊ ␊ });␊ ␊ - commonjsRegister("/$$rollup_base$$/fixtures/function/dynamic-require-package/node_modules/custom-module/entry.js", function (module, exports) {␊ - module.exports = 'custom-module';␊ - ␊ - });␊ + commonjsRegister("/$$rollup_base$$/fixtures/function/dynamic-require-relative-paths/sub/subsub/subsubmodule.js", function (module, exports) {␊ + module.exports = 'subsubmodule';␊ ␊ - commonjsRegister("/$$rollup_base$$/fixtures/function/dynamic-require-package", function (module, exports) {␊ - module.exports = commonjsRequire("/$$rollup_base$$/fixtures/function/dynamic-require-package/entry.js", null);␊ - });␊ - commonjsRegister("/$$rollup_base$$/fixtures/function/dynamic-require-package/sub", function (module, exports) {␊ - module.exports = commonjsRequire("/$$rollup_base$$/fixtures/function/dynamic-require-package/sub/entry.js", null);␊ - });␊ - commonjsRegister("/$$rollup_base$$/fixtures/function/dynamic-require-package/node_modules/custom-module", function (module, exports) {␊ - module.exports = commonjsRequire("/$$rollup_base$$/fixtures/function/dynamic-require-package/node_modules/custom-module/entry.js", null);␊ });␊ ␊ /* eslint-disable import/no-dynamic-require, global-require */␊ ␊ - function takeModule(name) {␊ - return commonjsRequire(name,"/$$rollup_base$$/fixtures/function/dynamic-require-package/sub");␊ - }␊ - ␊ - var sub = {␊ - parent: takeModule('..'),␊ - customModule: takeModule('custom-module')␊ - };␊ - ␊ - /* eslint-disable import/no-dynamic-require, global-require */␊ - ␊ - function takeModule$1(name) {␊ - return commonjsRequire(name,"/$$rollup_base$$/fixtures/function/dynamic-require-package");␊ + function takeModuleWithDelimiter(name, delimiter) {␊ + return commonjsRequire(`.${delimiter}${name.replace(/=/g, delimiter)}`,"/$$rollup_base$$/fixtures/function/dynamic-require-relative-paths");␊ }␊ ␊ - t.is(takeModule$1('.'), 'same-directory');␊ - t.is(takeModule$1('./'), 'same-directory');␊ - t.is(takeModule$1('.//'), 'same-directory');␊ - ␊ - t.is(takeModule$1('./sub'), 'sub');␊ - ␊ - t.is(takeModule$1('custom-module'), 'custom-module');␊ - t.deepEqual(sub, { parent: 'same-directory', customModule: 'custom-module' });␊ + t.is(takeModuleWithDelimiter('sub=submodule.js', '/'), 'submodule');␊ + t.is(takeModuleWithDelimiter('sub=subsub=subsubmodule.js', '/'), 'subsubmodule');␊ + t.is(takeModuleWithDelimiter('sub=submodule.js', '\\\\'), 'submodule');␊ + t.is(takeModuleWithDelimiter('sub=subsub=subsubmodule.js', '\\\\'), 'subsubmodule');␊ ␊ var main = {␊ ␊ @@ -2978,12 +3230,12 @@ Generated by [AVA](https://avajs.dev). `, } -## dynamic-require-package-sub +## dynamic-require-resolve-index > Snapshot 1 { - 'entry.js': `'use strict';␊ + 'main.js': `'use strict';␊ ␊ var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};␊ ␊ @@ -3145,41 +3397,72 @@ Generated by [AVA](https://avajs.dev). cachedModule.loaded = true;␊ return cachedModule.exports;␊ } }␊ - return require(path);␊ + throw new Error('Could not dynamically require "' + path + '". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.');␊ }␊ ␊ commonjsRequire.cache = DYNAMIC_REQUIRE_CACHE;␊ commonjsRequire.resolve = commonjsResolve;␊ ␊ - commonjsRegister("/$$rollup_base$$/fixtures/function/dynamic-require-package-sub/node_modules/custom-module/entry.js", function (module, exports) {␊ - module.exports = 'custom-module';␊ + commonjsRegister("/$$rollup_base$$/fixtures/function/dynamic-require-resolve-index/index.js", function (module, exports) {␊ + module.exports = 'same-directory';␊ ␊ });␊ ␊ - var main = "./entry.js";␊ - var require$$0 = {␊ - main: main␊ - };␊ + commonjsRegister("/$$rollup_base$$/fixtures/function/dynamic-require-resolve-index/sub/index.js", function (module, exports) {␊ + module.exports = 'sub';␊ ␊ - commonjsRegister("/$$rollup_base$$/fixtures/function/dynamic-require-package-sub/node_modules/custom-module/package.json", function (module, exports) {␊ - module.exports = require$$0;␊ });␊ ␊ - commonjsRegister("/$$rollup_base$$/fixtures/function/dynamic-require-package-sub/node_modules/custom-module", function (module, exports) {␊ - module.exports = commonjsRequire("/$$rollup_base$$/fixtures/function/dynamic-require-package-sub/node_modules/custom-module/entry.js", null);␊ + commonjsRegister("/$$rollup_base$$/fixtures/function/dynamic-require-resolve-index/node_modules/custom-module/index.js", function (module, exports) {␊ + module.exports = 'custom-module';␊ + ␊ });␊ ␊ - t.is(commonjsRequire("custom-module", "/$$rollup_base$$/fixtures/function/dynamic-require-package-sub/sub"), 'custom-module');␊ + commonjsRegister("/$$rollup_base$$/fixtures/function/dynamic-require-resolve-index", function (module, exports) {␊ + module.exports = commonjsRequire("/$$rollup_base$$/fixtures/function/dynamic-require-resolve-index/index.js", null);␊ + });␊ + commonjsRegister("/$$rollup_base$$/fixtures/function/dynamic-require-resolve-index/sub", function (module, exports) {␊ + module.exports = commonjsRequire("/$$rollup_base$$/fixtures/function/dynamic-require-resolve-index/sub/index.js", null);␊ + });␊ + commonjsRegister("/$$rollup_base$$/fixtures/function/dynamic-require-resolve-index/node_modules/custom-module", function (module, exports) {␊ + module.exports = commonjsRequire("/$$rollup_base$$/fixtures/function/dynamic-require-resolve-index/node_modules/custom-module/index.js", null);␊ + });␊ ␊ - var entry = {␊ + /* eslint-disable import/no-dynamic-require, global-require */␊ + ␊ + function takeModule(name) {␊ + return commonjsRequire(name,"/$$rollup_base$$/fixtures/function/dynamic-require-resolve-index/sub");␊ + }␊ ␊ + var sub = {␊ + parent: takeModule('..'),␊ + customModule: takeModule('custom-module')␊ };␊ ␊ - module.exports = entry;␊ + /* eslint-disable import/no-dynamic-require, global-require */␊ + ␊ + function takeModule$1(name) {␊ + return commonjsRequire(name,"/$$rollup_base$$/fixtures/function/dynamic-require-resolve-index");␊ + }␊ + ␊ + t.is(takeModule$1('.'), 'same-directory');␊ + t.is(takeModule$1('./'), 'same-directory');␊ + t.is(takeModule$1('.//'), 'same-directory');␊ + ␊ + t.is(takeModule$1('./sub'), 'sub');␊ + ␊ + t.is(takeModule$1('custom-module'), 'custom-module');␊ + t.deepEqual(sub, { parent: 'same-directory', customModule: 'custom-module' });␊ + ␊ + var main = {␊ + ␊ + };␊ + ␊ + module.exports = main;␊ `, } -## dynamic-require-relative-paths +## dynamic-require-resolve-reference > Snapshot 1 @@ -3346,32 +3629,37 @@ Generated by [AVA](https://avajs.dev). cachedModule.loaded = true;␊ return cachedModule.exports;␊ } }␊ - return require(path);␊ + throw new Error('Could not dynamically require "' + path + '". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.');␊ }␊ ␊ commonjsRequire.cache = DYNAMIC_REQUIRE_CACHE;␊ commonjsRequire.resolve = commonjsResolve;␊ ␊ - commonjsRegister("/$$rollup_base$$/fixtures/function/dynamic-require-relative-paths/sub/submodule.js", function (module, exports) {␊ - module.exports = 'submodule';␊ + commonjsRegister("/$$rollup_base$$/fixtures/function/dynamic-require-resolve-reference/node_modules/custom-module/index.js", function (module, exports) {␊ + module.exports = {␊ + foo: 'bar',␊ + };␊ ␊ });␊ ␊ - commonjsRegister("/$$rollup_base$$/fixtures/function/dynamic-require-relative-paths/sub/subsub/subsubmodule.js", function (module, exports) {␊ - module.exports = 'subsubmodule';␊ + commonjsRegister("/$$rollup_base$$/fixtures/function/dynamic-require-resolve-reference/node_modules/custom-module2/index.js", function (module, exports) {␊ + module.exports = () => {␊ + return commonjsRequire.resolve('custom-module',"/$$rollup_base$$/fixtures/function/dynamic-require-resolve-reference/node_modules/custom-module2");␊ + };␊ ␊ });␊ ␊ - /* eslint-disable import/no-dynamic-require, global-require */␊ - ␊ - function takeModuleWithDelimiter(name, delimiter) {␊ - return commonjsRequire(`.${delimiter}${name.replace(/=/g, delimiter)}`,"/$$rollup_base$$/fixtures/function/dynamic-require-relative-paths");␊ - }␊ + commonjsRegister("/$$rollup_base$$/fixtures/function/dynamic-require-resolve-reference/node_modules/custom-module", function (module, exports) {␊ + module.exports = commonjsRequire("/$$rollup_base$$/fixtures/function/dynamic-require-resolve-reference/node_modules/custom-module/index.js", null);␊ + });␊ + commonjsRegister("/$$rollup_base$$/fixtures/function/dynamic-require-resolve-reference/node_modules/custom-module2", function (module, exports) {␊ + module.exports = commonjsRequire("/$$rollup_base$$/fixtures/function/dynamic-require-resolve-reference/node_modules/custom-module2/index.js", null);␊ + });␊ ␊ - t.is(takeModuleWithDelimiter('sub=submodule.js', '/'), 'submodule');␊ - t.is(takeModuleWithDelimiter('sub=subsub=subsubmodule.js', '/'), 'subsubmodule');␊ - t.is(takeModuleWithDelimiter('sub=submodule.js', '\\\\'), 'submodule');␊ - t.is(takeModuleWithDelimiter('sub=subsub=subsubmodule.js', '\\\\'), 'subsubmodule');␊ + t.is(␊ + commonjsRequire("custom-module2", "/$$rollup_base$$/fixtures/function/dynamic-require-resolve-reference")(),␊ + '/$$rollup_base$$/fixtures/function/dynamic-require-resolve-reference/node_modules/custom-module'␊ + );␊ ␊ var main = {␊ ␊ @@ -3381,7 +3669,7 @@ Generated by [AVA](https://avajs.dev). `, } -## dynamic-require-resolve-index +## dynamic-require-targets-fallback > Snapshot 1 @@ -3554,56 +3842,20 @@ Generated by [AVA](https://avajs.dev). commonjsRequire.cache = DYNAMIC_REQUIRE_CACHE;␊ commonjsRequire.resolve = commonjsResolve;␊ ␊ - commonjsRegister("/$$rollup_base$$/fixtures/function/dynamic-require-resolve-index/index.js", function (module, exports) {␊ - module.exports = 'same-directory';␊ - ␊ - });␊ - ␊ - commonjsRegister("/$$rollup_base$$/fixtures/function/dynamic-require-resolve-index/sub/index.js", function (module, exports) {␊ - module.exports = 'sub';␊ - ␊ - });␊ - ␊ - commonjsRegister("/$$rollup_base$$/fixtures/function/dynamic-require-resolve-index/node_modules/custom-module/index.js", function (module, exports) {␊ - module.exports = 'custom-module';␊ - ␊ - });␊ + commonjsRegister("/$$rollup_base$$/fixtures/function/dynamic-require-targets-fallback/dep1.js", function (module, exports) {␊ + module.exports = 'dep';␊ ␊ - commonjsRegister("/$$rollup_base$$/fixtures/function/dynamic-require-resolve-index", function (module, exports) {␊ - module.exports = commonjsRequire("/$$rollup_base$$/fixtures/function/dynamic-require-resolve-index/index.js", null);␊ - });␊ - commonjsRegister("/$$rollup_base$$/fixtures/function/dynamic-require-resolve-index/sub", function (module, exports) {␊ - module.exports = commonjsRequire("/$$rollup_base$$/fixtures/function/dynamic-require-resolve-index/sub/index.js", null);␊ - });␊ - commonjsRegister("/$$rollup_base$$/fixtures/function/dynamic-require-resolve-index/node_modules/custom-module", function (module, exports) {␊ - module.exports = commonjsRequire("/$$rollup_base$$/fixtures/function/dynamic-require-resolve-index/node_modules/custom-module/index.js", null);␊ });␊ ␊ /* eslint-disable import/no-dynamic-require, global-require */␊ ␊ - function takeModule(name) {␊ - return commonjsRequire(name,"/$$rollup_base$$/fixtures/function/dynamic-require-resolve-index/sub");␊ - }␊ - ␊ - var sub = {␊ - parent: takeModule('..'),␊ - customModule: takeModule('custom-module')␊ - };␊ - ␊ - /* eslint-disable import/no-dynamic-require, global-require */␊ - ␊ - function takeModule$1(name) {␊ - return commonjsRequire(name,"/$$rollup_base$$/fixtures/function/dynamic-require-resolve-index");␊ + function takeModule(withName) {␊ + return commonjsRequire(withName,"/$$rollup_base$$/fixtures/function/dynamic-require-targets-fallback");␊ }␊ ␊ - t.is(takeModule$1('.'), 'same-directory');␊ - t.is(takeModule$1('./'), 'same-directory');␊ - t.is(takeModule$1('.//'), 'same-directory');␊ - ␊ - t.is(takeModule$1('./sub'), 'sub');␊ - ␊ - t.is(takeModule$1('custom-module'), 'custom-module');␊ - t.deepEqual(sub, { parent: 'same-directory', customModule: 'custom-module' });␊ + t.is(takeModule('./dep1.js'), 'dep');␊ + // The bundled code will run from test/helpers/util.js␊ + t.is(takeModule('../fixtures/function/dynamic-require-targets-fallback/dep2.js'), 'dep');␊ ␊ var main = {␊ ␊ @@ -3613,7 +3865,7 @@ Generated by [AVA](https://avajs.dev). `, } -## dynamic-require-resolve-reference +## dynamic-require-targets-no-fallback > Snapshot 1 @@ -3780,38 +4032,29 @@ Generated by [AVA](https://avajs.dev). cachedModule.loaded = true;␊ return cachedModule.exports;␊ } }␊ - return require(path);␊ + throw new Error('Could not dynamically require "' + path + '". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.');␊ }␊ ␊ commonjsRequire.cache = DYNAMIC_REQUIRE_CACHE;␊ commonjsRequire.resolve = commonjsResolve;␊ ␊ - commonjsRegister("/$$rollup_base$$/fixtures/function/dynamic-require-resolve-reference/node_modules/custom-module/index.js", function (module, exports) {␊ - module.exports = {␊ - foo: 'bar',␊ - };␊ + commonjsRegister("/$$rollup_base$$/fixtures/function/dynamic-require-targets-no-fallback/dep1.js", function (module, exports) {␊ + module.exports = 'dep';␊ ␊ });␊ ␊ - commonjsRegister("/$$rollup_base$$/fixtures/function/dynamic-require-resolve-reference/node_modules/custom-module2/index.js", function (module, exports) {␊ - module.exports = () => {␊ - return commonjsRequire.resolve('custom-module',"/$$rollup_base$$/fixtures/function/dynamic-require-resolve-reference/node_modules/custom-module2");␊ - };␊ + /* eslint-disable import/no-dynamic-require, global-require */␊ ␊ - });␊ + function takeModule(withName) {␊ + return commonjsRequire(withName,"/$$rollup_base$$/fixtures/function/dynamic-require-targets-no-fallback");␊ + }␊ ␊ - commonjsRegister("/$$rollup_base$$/fixtures/function/dynamic-require-resolve-reference/node_modules/custom-module", function (module, exports) {␊ - module.exports = commonjsRequire("/$$rollup_base$$/fixtures/function/dynamic-require-resolve-reference/node_modules/custom-module/index.js", null);␊ - });␊ - commonjsRegister("/$$rollup_base$$/fixtures/function/dynamic-require-resolve-reference/node_modules/custom-module2", function (module, exports) {␊ - module.exports = commonjsRequire("/$$rollup_base$$/fixtures/function/dynamic-require-resolve-reference/node_modules/custom-module2/index.js", null);␊ + t.is(takeModule('./dep1.js'), 'dep');␊ + t.throws(() => takeModule('./dep2.js'), {␊ + message:␊ + 'Could not dynamically require "./dep2.js". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.'␊ });␊ ␊ - t.is(␊ - commonjsRequire("custom-module2", "/$$rollup_base$$/fixtures/function/dynamic-require-resolve-reference")(),␊ - '/$$rollup_base$$/fixtures/function/dynamic-require-resolve-reference/node_modules/custom-module'␊ - );␊ - ␊ var main = {␊ ␊ };␊ @@ -4275,7 +4518,7 @@ Generated by [AVA](https://avajs.dev). }␊ ␊ var encode = createCommonjsModule(function (module, exports) {␊ - exports.encodeURIComponent = function() {␊ + exports.encodeURIComponent = function () {␊ return encodeURIComponent(this.str);␊ };␊ ␊ @@ -5101,7 +5344,7 @@ Generated by [AVA](https://avajs.dev). { 'main.js': `'use strict';␊ ␊ - var multiply = function(a, b) {␊ + var multiply = function (a, b) {␊ return a * b;␊ };␊ ␊ @@ -5109,7 +5352,7 @@ Generated by [AVA](https://avajs.dev). ␊ /* eslint-disable global-require */␊ ␊ - var main = function() {␊ + var main = function () {␊ return multiply(2, foo);␊ };␊ ␊ @@ -6567,8 +6810,8 @@ Generated by [AVA](https://avajs.dev). return fn(module, module.exports), module.exports;␊ }␊ ␊ - function commonjsRequire (target) {␊ - throw new Error('Could not dynamically require "' + target + '". Please configure the dynamicRequireTargets option of @rollup/plugin-commonjs appropriately for this require call to behave properly.');␊ + function commonjsRequire (path) {␊ + throw new Error('Could not dynamically require "' + path + '". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.');␊ }␊ ␊ var foo = createCommonjsModule(function (module) {␊ @@ -6595,8 +6838,8 @@ Generated by [AVA](https://avajs.dev). return fn(module, module.exports), module.exports;␊ }␊ ␊ - function commonjsRequire (target) {␊ - throw new Error('Could not dynamically require "' + target + '". Please configure the dynamicRequireTargets option of @rollup/plugin-commonjs appropriately for this require call to behave properly.');␊ + function commonjsRequire (path) {␊ + throw new Error('Could not dynamically require "' + path + '". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.');␊ }␊ ␊ var foo = createCommonjsModule(function (module) {␊ @@ -6633,33 +6876,3 @@ Generated by [AVA](https://avajs.dev). module.exports = main;␊ `, } - -## unsupported-dynamic-require - -> Snapshot 1 - - { - 'main.js': `'use strict';␊ - ␊ - function commonjsRequire (target) {␊ - throw new Error('Could not dynamically require "' + target + '". Please configure the dynamicRequireTargets option of @rollup/plugin-commonjs appropriately for this require call to behave properly.');␊ - }␊ - ␊ - /* eslint-disable import/no-dynamic-require, global-require */␊ - ␊ - t.throws(() => commonjsRequire(getRequireTarget()), {␊ - message:␊ - 'Could not dynamically require "foo-bar". Please configure the dynamicRequireTargets option of @rollup/plugin-commonjs appropriately for this require call to behave properly.'␊ - });␊ - ␊ - function getRequireTarget() {␊ - return 'foo-bar';␊ - }␊ - ␊ - var main = {␊ - ␊ - };␊ - ␊ - module.exports = main;␊ - `, - } diff --git a/packages/commonjs/test/snapshots/function.js.snap b/packages/commonjs/test/snapshots/function.js.snap index 2522d27a68b0de360041b9dc7a42ff59ad3ca268..a557beb7ccfab4810bd44020717754a39ce5a0ce 100644 GIT binary patch literal 15704 zcma*NbF65=v+ucW+qP}nwsp2`+qP}nwr$(?KHKlyJ8zQ7%=~U%|FKf}RHu_#Yo+>I zT`j04NT6(MXzyfh=S<+r1O)`Z?f)>6cBQT2>dYsZlEc`B9|ZyM-vjtY7t&itb;XZ< zWD!PN`&HC^xqrI3iN#`rN%uT4RZ3gRLb{;lfb=O*hFLnDJ&6n!(4?w55DF+obRSsM z6;&ZWr6xR|091r+qp~qvK~(VgsOz)qZpNpHG)eMP*LRiVZO7}@_qOBA@0Qc-wwR)f z>hc0xttOqBzwz`@decp-XK%L>=+_JPOS!M`-6(_w%mj zX+3%&&SbTm;>Ar+bi?TwP@Av)<&!<+ccW!!I9k0IE#owgM+}}r6 z)Dk>iX+@!er_R*9-!S#Jm)y3Cm>7CsONJMpzb64XdO1EL+jDZBZhP45d}uv_q7`n_ zVETAIhAW_Ey$=0++NehhTU}%SUPuF(C}iHe_u~TbSoe3I_G^0E;X#tClH%q27{%mp z&MoJ0M?+56S`FXb7ys`=yDF8`j$?JdF0|x9hhu<6Nw! zy>D=x-{-vC9~sdK**%ryqFBz)pwZv=o#m(8@5j}+%vC!D#mm$t)DnjNDhHavkD#@J>Jfaz{D>_c6`oHh{PxQBY zE`Oevhg6e4ep(`#dUUysz6-xyJ5CpL?XvkFy_)`OC6`DhtHJ1oy1o0GzFy?spV~fo zE(7*|-^eSdaQgMmDp1z*ve%+LZC{RoEzQYS?x_Si3`+jj7U90!yvlSk1xB{NF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Sqf( zq9%c&Ja?Q1H?XD_pDzq$;s|ZGlZ^!DV*m7x12D)F4VxxZ@cg3A05vYE^*WTm7sjODPfUI9EoMU%MjZ%)QR!qC>1XH5UVY zYSK(Ja|pg?M(1wsj@vp0j{vK=oQHUMbGO{8c%0m(X+2sRVnmX6snF2fhuHvC5%lIM zbFzrbXNB(UgHG8Ya|umn3Lyy)JnHI=m1Fhk)mFMdcW3x%)0)@g`Io`~K@g{~00x8X aK8m|9otsYeuk6`3I0BKR?07I3$bSQEU11jh diff --git a/packages/commonjs/test/types.ts b/packages/commonjs/test/types.ts index 49fc2decf..d119c561f 100644 --- a/packages/commonjs/test/types.ts +++ b/packages/commonjs/test/types.ts @@ -15,6 +15,7 @@ const config: RollupOptions = { exclude: ['node_modules/foo/**', 'node_modules/bar/**', /node_modules/], extensions: ['.js', '.coffee'], ignoreGlobal: false, + ignoreDynamicRequires: true, requireReturnsDefault: 'auto', sourceMap: false, transformMixedEsModules: false, diff --git a/packages/commonjs/types/index.d.ts b/packages/commonjs/types/index.d.ts index 87b0b3f61..2b0b06797 100644 --- a/packages/commonjs/types/index.d.ts +++ b/packages/commonjs/types/index.d.ts @@ -35,10 +35,23 @@ interface RollupCommonJSOptions { */ ignoreGlobal?: boolean; /** - * If false, skips source map generation for CommonJS modules. This will improve performance. + * If false, skips source map generation for CommonJS modules. This will + * improve performance. * @default true */ sourceMap?: boolean; + /** + * Some `require` calls cannot be resolved statically to be translated to + * imports. + * When this option is set to `false`, the generated code will either + * directly throw an error when such a call is encountered or, when + * `dynamicRequireTargets` is used, when such a call cannot be resolved with a + * configured dynamic require target. + * Setting this option to `true` will instead leave the `require` call in the + * code or use it as a fallback for `dynamicRequireTargets`. + * @default false + */ + ignoreDynamicRequires?: boolean; /** * Instructs the plugin whether to enable mixed module transformations. This * is useful in scenarios with modules that contain a mix of ES `import`