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

fix: force esbuild target in zisi #681

Merged
merged 3 commits into from
Sep 29, 2021
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/runtimes/node/list_imports.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,14 @@ const listImports = async ({ path }) => {

try {
await esbuild.build({
entryPoints: [path],
bundle: true,
entryPoints: [path],
logLevel: 'error',
logLimit: 1,
outfile: targetPath,
platform: 'node',
plugins: [getListImportsPlugin({ imports, path })],
target: 'esnext',
})
} finally {
await safeUnlink(targetPath)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
const { stack } = require('@netlify/mock-package/stack')

module.exports = { stack }

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"name": "local-node-module-destructure-require",
"version": "1.0.0",
"dependencies": {
"@netlify/mock-package": "1.0.0"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"compilerOptions": {
"target": "ES5"
}
}
15 changes: 15 additions & 0 deletions tests/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,21 @@ testBundlers('Can require deep paths in node modules', [ESBUILD, ESBUILD_ZISI, D
}
})

testBundlers(
'Can require Node modules with destructuring expressions',
[ESBUILD, ESBUILD_ZISI, DEFAULT],
async (bundler, t) => {
await zipNode(t, `local-node-module-destructure-require`, {
opts: { config: { '*': { nodeBundler: bundler } } },
})

// TO DO: Remove when `parseWithEsbuild` feature flag is decommissioned.
await zipNode(t, `local-node-module-destructure-require`, {
opts: { config: { '*': { nodeBundler: bundler } }, featureFlags: { parseWithEsbuild: true } },
})
},
)

testBundlers('Can require scoped node modules', [ESBUILD, ESBUILD_ZISI, DEFAULT], async (bundler, t) => {
await zipNode(t, 'node-module-scope', { opts: { config: { '*': { nodeBundler: bundler } } } })
})
Expand Down