diff --git a/src/runtimes/node/bundler.js b/src/runtimes/node/bundler.js index a686f8278..0c1d625e8 100644 --- a/src/runtimes/node/bundler.js +++ b/src/runtimes/node/bundler.js @@ -57,7 +57,7 @@ const bundleJsFile = async function ({ basePath, includedPaths: dynamicImportsIncludedPaths, moduleNames: nodeModulesWithDynamicImports, - processImports: config.processDynamicNodeImports === true, + processImports: config.processDynamicNodeImports !== false, srcDir, }), ] diff --git a/tests/main.js b/tests/main.js index 4b4167f57..7026b88e8 100644 --- a/tests/main.js +++ b/tests/main.js @@ -1424,10 +1424,13 @@ test('Returns an empty list of modules with dynamic imports if the modules are m t.is(files[0].nodeModulesWithDynamicImports.length, 0) }) -test('Leaves dynamic imports untouched when the `processDynamicNodeImports` configuration property is not `true`', async (t) => { +test('Leaves dynamic imports untouched when the `processDynamicNodeImports` configuration property is `false`', async (t) => { const fixtureName = 'node-module-dynamic-import-template-literal' const { tmpDir } = await zipNode(t, fixtureName, { - opts: { basePath: join(FIXTURES_DIR, fixtureName), config: { '*': { nodeBundler: ESBUILD } } }, + opts: { + basePath: join(FIXTURES_DIR, fixtureName), + config: { '*': { nodeBundler: ESBUILD, processDynamicNodeImports: false } }, + }, }) const functionSource = await pReadFile(`${tmpDir}/function.js`, 'utf8') @@ -1445,7 +1448,7 @@ test('Adds a runtime shim and includes the files needed for dynamic imports usin const { files, tmpDir } = await zipNode(t, fixtureName, { opts: { basePath: join(FIXTURES_DIR, fixtureName), - config: { '*': { nodeBundler: ESBUILD, processDynamicNodeImports: true } }, + config: { '*': { nodeBundler: ESBUILD } }, }, }) @@ -1466,7 +1469,7 @@ test('Leaves dynamic imports untouched when the files required to resolve the ex const { tmpDir } = await zipNode(t, fixtureName, { opts: { basePath: join(FIXTURES_DIR, fixtureName), - config: { '*': { nodeBundler: ESBUILD, processDynamicNodeImports: true } }, + config: { '*': { nodeBundler: ESBUILD } }, }, }) const functionSource = await pReadFile(`${tmpDir}/function.js`, 'utf8') @@ -1482,7 +1485,7 @@ test('Adds a runtime shim and includes the files needed for dynamic imports usin const { tmpDir } = await zipNode(t, fixtureName, { opts: { basePath: join(FIXTURES_DIR, fixtureName), - config: { '*': { nodeBundler: ESBUILD, processDynamicNodeImports: true } }, + config: { '*': { nodeBundler: ESBUILD } }, }, }) @@ -1501,7 +1504,7 @@ test('The dynamic import runtime shim handles files in nested directories', asyn const { tmpDir } = await zipNode(t, fixtureName, { opts: { basePath: join(FIXTURES_DIR, fixtureName), - config: { '*': { nodeBundler: ESBUILD, processDynamicNodeImports: true } }, + config: { '*': { nodeBundler: ESBUILD } }, }, }) @@ -1523,7 +1526,7 @@ test('The dynamic import runtime shim handles files in nested directories when u opts: { archiveFormat: 'none', basePath: join(FIXTURES_DIR, fixtureName), - config: { '*': { nodeBundler: ESBUILD, processDynamicNodeImports: true } }, + config: { '*': { nodeBundler: ESBUILD } }, }, }) @@ -1544,7 +1547,7 @@ test('Negated files in `included_files` are excluded from the bundle even if the const { tmpDir } = await zipNode(t, fixtureName, { opts: { basePath: join(FIXTURES_DIR, fixtureName), - config: { '*': { includedFiles: ['!lang/en.*'], nodeBundler: ESBUILD, processDynamicNodeImports: true } }, + config: { '*': { includedFiles: ['!lang/en.*'], nodeBundler: ESBUILD } }, }, }) @@ -1564,7 +1567,7 @@ test('Creates dynamic import shims for functions with the same name and same shi length: FUNCTION_COUNT, opts: { basePath: join(FIXTURES_DIR, fixtureName), - config: { '*': { nodeBundler: ESBUILD, processDynamicNodeImports: true } }, + config: { '*': { nodeBundler: ESBUILD } }, }, }) @@ -1585,7 +1588,7 @@ test('Creates dynamic import shims for functions using `zipFunction`', async (t) const fixtureDir = join(FIXTURES_DIR, 'node-module-dynamic-import-2') const result = await zipFunction(join(fixtureDir, 'function.js'), tmpDir, { basePath: fixtureDir, - config: { '*': { nodeBundler: 'esbuild', processDynamicNodeImports: true } }, + config: { '*': { nodeBundler: 'esbuild' } }, }) await unzipFiles([result])