Skip to content
This repository has been archived by the owner on May 22, 2024. It is now read-only.

Commit

Permalink
feat: change default value of processDynamicNodeImports (#603)
Browse files Browse the repository at this point in the history
* feat!: change default value of processDynamicNodeImports

* chore: update test title
  • Loading branch information
eduardoboucas committed Sep 20, 2021
1 parent ff051cd commit cdbcad2
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/runtimes/node/bundler.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ const bundleJsFile = async function ({
basePath,
includedPaths: dynamicImportsIncludedPaths,
moduleNames: nodeModulesWithDynamicImports,
processImports: config.processDynamicNodeImports === true,
processImports: config.processDynamicNodeImports !== false,
srcDir,
}),
]
Expand Down
23 changes: 13 additions & 10 deletions tests/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -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')

Expand All @@ -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 } },
},
})

Expand All @@ -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')
Expand All @@ -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 } },
},
})

Expand All @@ -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 } },
},
})

Expand All @@ -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 } },
},
})

Expand All @@ -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 } },
},
})

Expand All @@ -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 } },
},
})

Expand All @@ -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])
Expand Down

1 comment on commit cdbcad2

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⏱ Benchmark results

largeDepsEsbuild: 12.8s

largeDepsZisi: 1m 9s

Please sign in to comment.