Skip to content

Commit ac7fd04

Browse files
authored
Revert "fix #1874: node defaults to --packages=external" (#3820)
This reverts commit 196dcad.
1 parent 626ac2c commit ac7fd04

File tree

5 files changed

+34
-15
lines changed

5 files changed

+34
-15
lines changed

CHANGELOG.md

+8
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,14 @@
22

33
## Unreleased
44

5+
* Revert the recent change to avoid bundling dependencies for node ([#3819](https://github.com/evanw/esbuild/issues/3819))
6+
7+
This release reverts the recent change in version 0.22.0 that made `--packages=external` the default behavior with `--platform=node`. The default is now back to `--packages=bundle`.
8+
9+
I've just been made aware that Amazon doesn't pin their dependencies in their "AWS CDK" product, which means that whenever esbuild publishes a new release, many people (potentially everyone?) using their SDK around the world instantly starts using it without Amazon checking that it works first. This change in version 0.22.0 happened to break their SDK. I'm amazed that things haven't broken before this point. This revert attempts to avoid these problems for Amazon's customers. Hopefully Amazon will pin their dependencies in the future.
10+
11+
In addition, this is probably a sign that esbuild is used widely enough that it now needs to switch to a more complicated release model. I may have esbuild use a beta channel model for further development.
12+
513
* Fix preserving collapsed JSX whitespace ([#3818](https://github.com/evanw/esbuild/issues/3818))
614

715
When transformed, certain whitespace inside JSX elements is ignored completely if it collapses to an empty string. However, the whitespace should only be ignored if the JSX is being transformed, not if it's being preserved. This release fixes a bug where esbuild was previously incorrectly ignoring collapsed whitespace with `--jsx=preserve`. Here is an example:

Makefile

+1-2
Original file line numberDiff line numberDiff line change
@@ -753,7 +753,7 @@ test-tsc: esbuild | github/tsc
753753
cp -r github/tsc/src github/tsc/scripts demo/tsc
754754
cp github/tsc/lib/*.d.ts demo/tsc/built/local
755755
cd demo/tsc && node scripts/processDiagnosticMessages.mjs src/compiler/diagnosticMessages.json
756-
./esbuild --bundle demo/tsc/src/tsc/tsc.ts --outfile=demo/tsc/built/local/tsc.js --platform=node --target=es2018
756+
./esbuild --bundle demo/tsc/src/tsc/tsc.ts --outfile=demo/tsc/built/local/tsc.js --platform=node --target=es2018 --packages=external
757757
echo '{"dependencies":{"@types/node":"20.2.5","@types/microsoft__typescript-etw":"0.1.1","@types/source-map-support":"0.5.6"}}' > demo/tsc/package.json
758758
cd demo/tsc && npm i --silent && echo 'Type checking tsc using tsc...' && time -p node ./built/local/tsc.js -p src/compiler
759759

@@ -769,7 +769,6 @@ TEST_ROLLUP_REPLACE += "paths": { "package.json": [".\/package.json"] },
769769
TEST_ROLLUP_FLAGS += --bundle
770770
TEST_ROLLUP_FLAGS += --external:fsevents
771771
TEST_ROLLUP_FLAGS += --outfile=dist/rollup.js
772-
TEST_ROLLUP_FLAGS += --packages=bundle
773772
TEST_ROLLUP_FLAGS += --platform=node
774773
TEST_ROLLUP_FLAGS += --target=es6
775774
TEST_ROLLUP_FLAGS += src/node-entry.ts

pkg/api/api_impl.go

+3-5
Original file line numberDiff line numberDiff line change
@@ -216,11 +216,9 @@ func validateASCIIOnly(value Charset) bool {
216216
}
217217
}
218218

219-
func validateExternalPackages(value Packages, platform Platform) bool {
219+
func validateExternalPackages(value Packages) bool {
220220
switch value {
221-
case PackagesDefault:
222-
return platform == PlatformNode
223-
case PackagesBundle:
221+
case PackagesDefault, PackagesBundle:
224222
return false
225223
case PackagesExternal:
226224
return true
@@ -1280,7 +1278,7 @@ func validateBuildOptions(
12801278
ExtensionToLoader: validateLoaders(log, buildOpts.Loader),
12811279
ExtensionOrder: validateResolveExtensions(log, buildOpts.ResolveExtensions),
12821280
ExternalSettings: validateExternals(log, realFS, buildOpts.External),
1283-
ExternalPackages: validateExternalPackages(buildOpts.Packages, buildOpts.Platform),
1281+
ExternalPackages: validateExternalPackages(buildOpts.Packages),
12841282
PackageAliases: validateAlias(log, realFS, buildOpts.Alias),
12851283
TSConfigPath: validatePath(log, realFS, buildOpts.Tsconfig, "tsconfig path"),
12861284
TSConfigRaw: buildOpts.TsconfigRaw,

scripts/end-to-end-tests.js

+19-4
Original file line numberDiff line numberDiff line change
@@ -8108,9 +8108,7 @@ for (const flags of [[], ['--bundle']]) {
81088108
}
81098109
}`,
81108110
}),
8111-
8112-
// Check the default behavior of "--platform=node"
8113-
test(['in.js', '--outfile=node.js', '--bundle', '--platform=node', '--format=esm'].concat(flags), {
8111+
test(['in.js', '--outfile=node.js', '--bundle', '--platform=node', '--packages=external', '--format=esm'].concat(flags), {
81148112
'in.js': `import abc from 'pkg'; if (abc !== 'import') throw 'fail'`,
81158113
'node_modules/pkg/fail.js': `TEST FAILED`, // This package should not be bundled
81168114
'node_modules/pkg/require.cjs': `module.exports = 'require'`,
@@ -8125,7 +8123,7 @@ for (const flags of [[], ['--bundle']]) {
81258123
}
81268124
}`,
81278125
}),
8128-
test(['in.js', '--outfile=node.js', '--bundle', '--platform=node', '--format=cjs'].concat(flags), {
8126+
test(['in.js', '--outfile=node.js', '--bundle', '--platform=node', '--packages=external', '--format=cjs'].concat(flags), {
81298127
'in.js': `import abc from 'pkg'; if (abc !== 'require') throw 'fail'`,
81308128
'node_modules/pkg/fail.js': `TEST FAILED`, // This package should not be bundled
81318129
'node_modules/pkg/require.cjs': `module.exports = 'require'`,
@@ -8141,6 +8139,23 @@ for (const flags of [[], ['--bundle']]) {
81418139
}`,
81428140
}),
81438141

8142+
// Check the default behavior of "--platform=node"
8143+
test(['in.js', '--outfile=node.js', '--bundle', '--platform=node', '--format=esm'].concat(flags), {
8144+
'in.js': `import abc from 'pkg'; if (abc !== 'module') throw 'fail'`,
8145+
'node_modules/pkg/module.js': `export default 'module'`,
8146+
'node_modules/pkg/require.cjs': `module.exports = 'require'`,
8147+
'node_modules/pkg/import.mjs': `export default 'import'`,
8148+
'node_modules/pkg/package.json': `{
8149+
"exports": {
8150+
".": {
8151+
"module": "./module.js",
8152+
"import": "./import.mjs",
8153+
"require": "./require.cjs"
8154+
}
8155+
}
8156+
}`,
8157+
}),
8158+
81448159
// This is an edge case for extensionless files. The file should be treated
81458160
// as CommonJS even though package.json says "type": "module" because that
81468161
// only applies to ".js" files in node, not to all JavaScript files.

scripts/test-yarnpnp.js

+3-4
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ const ESBUILD_BINARY_PATH = esbuild.buildBinary()
77
const rootDir = path.join(__dirname, '..', 'require', 'yarnpnp')
88

99
function run(command) {
10-
console.log('\n\033[37m' + '$ ' + command + '\033[0m')
10+
console.log('\n\x1B[37m' + '$ ' + command + '\x1B[0m')
1111
child_process.execSync(command, { cwd: rootDir, stdio: 'inherit' })
1212
}
1313

@@ -66,20 +66,19 @@ function runTests() {
6666
'in.mjs',
6767
'--bundle',
6868
'--log-level=debug',
69-
'--packages=bundle',
7069
'--platform=node',
7170
'--outfile=out-native.js',
7271
], { cwd: rootDir, stdio: 'inherit' })
7372
run('node out-native.js')
7473

7574
// Test the WebAssembly build
7675
esbuild.buildWasmLib(ESBUILD_BINARY_PATH)
77-
run('node ../../npm/esbuild-wasm/bin/esbuild in.mjs --bundle --log-level=debug --packages=bundle --platform=node --outfile=out-wasm.js')
76+
run('node ../../npm/esbuild-wasm/bin/esbuild in.mjs --bundle --log-level=debug --platform=node --outfile=out-wasm.js')
7877
run('node out-wasm.js')
7978

8079
// Test the WebAssembly build when run through Yarn's file system shim
8180
esbuild.buildWasmLib(ESBUILD_BINARY_PATH)
82-
run('yarn node ../../npm/esbuild-wasm/bin/esbuild in.mjs --bundle --log-level=debug --packages=bundle --platform=node --outfile=out-wasm-yarn.js')
81+
run('yarn node ../../npm/esbuild-wasm/bin/esbuild in.mjs --bundle --log-level=debug --platform=node --outfile=out-wasm-yarn.js')
8382
run('node out-wasm-yarn.js')
8483
}
8584

0 commit comments

Comments
 (0)