Skip to content

Commit 9bf5a79

Browse files
committed
remove an extra "use strict" directive (#2264)
1 parent 87fad6f commit 9bf5a79

File tree

4 files changed

+33
-0
lines changed

4 files changed

+33
-0
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@
3939

4040
Previously bundling with esbuild when inside a sandbox environment which does not have permission to access the parent directory did not work because esbuild would try to read the directory to search for a `node_modules` folder and would then fail the build when that failed. In practice this caused issues with running esbuild with `sandbox-exec` on macOS. With this release, esbuild will treat directories with permission failures as empty to allow for the `node_modules` search to continue past the denied directory and into its parent directory. This means it should now be possible to bundle with esbuild in these situations. This fix is similar to the fix in version 0.9.1 but is for `EPERM` while that fix was for `EACCES`.
4141

42+
* Remove an irrelevant extra `"use strict"` directive ([#2264](https://github.com/evanw/esbuild/issues/2264))
43+
44+
The presence of a `"use strict"` directive in the output file is controlled by the presence of one in the entry point. However, there was a bug that would include one twice if the output format is ESM. This bug has been fixed.
45+
4246
## 0.14.39
4347

4448
* Fix code generation for `export default` and `/* @__PURE__ */` call ([#2203](https://github.com/evanw/esbuild/issues/2203))

internal/bundler/bundler_default_test.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2788,6 +2788,23 @@ func TestUseStrictDirectiveBundleIssue1837(t *testing.T) {
27882788
})
27892789
}
27902790

2791+
func TestUseStrictDirectiveBundleIssue2264(t *testing.T) {
2792+
default_suite.expectBundled(t, bundled{
2793+
files: map[string]string{
2794+
"/entry.js": `
2795+
'use strict'
2796+
export let a = 1
2797+
`,
2798+
},
2799+
entryPaths: []string{"/entry.js"},
2800+
options: config.Options{
2801+
Mode: config.ModeBundle,
2802+
AbsOutputFile: "/out.js",
2803+
OutputFormat: config.FormatESModule,
2804+
},
2805+
})
2806+
}
2807+
27912808
func TestNoOverwriteInputFileError(t *testing.T) {
27922809
default_suite.expectBundled(t, bundled{
27932810
files: map[string]string{

internal/bundler/linker.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4363,6 +4363,7 @@ func (c *linkerContext) generateEntryPointTailJS(
43634363
}
43644364

43654365
tree := repr.AST
4366+
tree.Directive = ""
43664367
tree.Parts = []js_ast.Part{{Stmts: stmts}}
43674368

43684369
// Indent the file if everything is wrapped in an IIFE

internal/bundler/snapshots/snapshots_default.txt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3779,6 +3779,17 @@ TestUseStrictDirectiveBundleIssue1837
37793779
console.log(require_cjs());
37803780
})();
37813781

3782+
================================================================================
3783+
TestUseStrictDirectiveBundleIssue2264
3784+
---------- /out.js ----------
3785+
"use strict";
3786+
3787+
// entry.js
3788+
var a = 1;
3789+
export {
3790+
a
3791+
};
3792+
37823793
================================================================================
37833794
TestUseStrictDirectiveMinifyNoBundle
37843795
---------- /out.js ----------

0 commit comments

Comments
 (0)