-
-
Notifications
You must be signed in to change notification settings - Fork 593
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(commonjs)!: default strictRequires to true (#1639)
* feat(commonjs)!: default strictRequires to true * test: update fixtures * test: update different values * test: update some tests to use auto * test: adapt assertion While the error message has a different variable name, the point of the test is that we get an error. * test: correctly pass options in test Unfortunately, I did not find a way to detect this case from the plugin and show a warning. * fix(commonjs): respect defaultIsModuleExports:false for ES imports from wrapped CommonJS * test: adapt assertions for wrapped CommonJS * docs: improve readme to explain about CommonJS entry points * test: allow tests to specify an entry point for running the code * test: refine late-entry tests * fix(commonjs): treat moduleSideEffects as __PURE__ comments for wrapped modules * fix(commonjs): treat moduleSideEffects as __PURE__ comments for proxied wrapped modules --------- Co-authored-by: Lukas Taegert-Atkinson <[email protected]>
- Loading branch information
1 parent
274b72c
commit 8f02987
Showing
75 changed files
with
4,787 additions
and
1,744 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 12 additions & 5 deletions
17
packages/commonjs/test/fixtures/form/async-function/output.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,15 @@ | ||
import * as commonjsHelpers from "_commonjsHelpers.js"; | ||
|
||
var input = async function () { | ||
// TODO | ||
}; | ||
var input; | ||
var hasRequiredInput; | ||
|
||
export default /*@__PURE__*/commonjsHelpers.getDefaultExportFromCjs(input); | ||
export { input as __moduleExports }; | ||
function requireInput () { | ||
if (hasRequiredInput) return input; | ||
hasRequiredInput = 1; | ||
input = async function () { | ||
// TODO | ||
}; | ||
return input; | ||
} | ||
|
||
export { requireInput as __require }; |
15 changes: 11 additions & 4 deletions
15
packages/commonjs/test/fixtures/form/compiled-esm-assign-exports/output.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,15 @@ | ||
import * as commonjsHelpers from "_commonjsHelpers.js"; | ||
import { __exports as input } from "\u0000fixtures/form/compiled-esm-assign-exports/input.js?commonjs-exports"; | ||
|
||
input.__esModule = true; | ||
var _default = input.default = 'x'; | ||
var foo = input.foo = 'foo'; | ||
var hasRequiredInput; | ||
|
||
export { input as __moduleExports, foo, _default as default }; | ||
function requireInput () { | ||
if (hasRequiredInput) return input; | ||
hasRequiredInput = 1; | ||
input.__esModule = true; | ||
input.default = 'x'; | ||
input.foo = 'foo'; | ||
return input; | ||
} | ||
|
||
export { requireInput as __require }; |
15 changes: 11 additions & 4 deletions
15
packages/commonjs/test/fixtures/form/compiled-esm-assign-module/output.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,15 @@ | ||
import * as commonjsHelpers from "_commonjsHelpers.js"; | ||
import { __exports as input } from "\u0000fixtures/form/compiled-esm-assign-module/input.js?commonjs-exports"; | ||
|
||
input.__esModule = true; | ||
var _default = input.default = 'x'; | ||
var foo = input.foo = 'foo'; | ||
var hasRequiredInput; | ||
|
||
export { input as __moduleExports, foo, _default as default }; | ||
function requireInput () { | ||
if (hasRequiredInput) return input; | ||
hasRequiredInput = 1; | ||
input.__esModule = true; | ||
input.default = 'x'; | ||
input.foo = 'foo'; | ||
return input; | ||
} | ||
|
||
export { requireInput as __require }; |
15 changes: 11 additions & 4 deletions
15
packages/commonjs/test/fixtures/form/compiled-esm-deconflict/output.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,16 @@ | ||
import * as commonjsHelpers from "_commonjsHelpers.js"; | ||
import { __exports as input } from "\u0000fixtures/form/compiled-esm-deconflict/input.js?commonjs-exports"; | ||
|
||
Object.defineProperty(input, '__esModule', { value: true }); | ||
var foo_1 = input.foo = 'bar'; | ||
var hasRequiredInput; | ||
|
||
const foo = 'also bar'; | ||
function requireInput () { | ||
if (hasRequiredInput) return input; | ||
hasRequiredInput = 1; | ||
Object.defineProperty(input, '__esModule', { value: true }); | ||
input.foo = 'bar'; | ||
|
||
export { input as __moduleExports, foo_1 as foo, input as default }; | ||
const foo = 'also bar'; | ||
return input; | ||
} | ||
|
||
export { requireInput as __require }; |
11 changes: 9 additions & 2 deletions
11
packages/commonjs/test/fixtures/form/compiled-esm-define-exports-empty/output.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,13 @@ | ||
import * as commonjsHelpers from "_commonjsHelpers.js"; | ||
import { __exports as input } from "\u0000fixtures/form/compiled-esm-define-exports-empty/input.js?commonjs-exports"; | ||
|
||
Object.defineProperty(input, "__esModule", { value: true }); | ||
var hasRequiredInput; | ||
|
||
export { input as __moduleExports, input as default }; | ||
function requireInput () { | ||
if (hasRequiredInput) return input; | ||
hasRequiredInput = 1; | ||
Object.defineProperty(input, "__esModule", { value: true }); | ||
return input; | ||
} | ||
|
||
export { requireInput as __require }; |
15 changes: 11 additions & 4 deletions
15
packages/commonjs/test/fixtures/form/compiled-esm-define-exports/output.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,15 @@ | ||
import * as commonjsHelpers from "_commonjsHelpers.js"; | ||
import { __exports as input } from "\u0000fixtures/form/compiled-esm-define-exports/input.js?commonjs-exports"; | ||
|
||
Object.defineProperty(input, '__esModule', { value: true }); | ||
var _default = input.default = 'x'; | ||
var foo = input.foo = 'foo'; | ||
var hasRequiredInput; | ||
|
||
export { input as __moduleExports, foo, _default as default }; | ||
function requireInput () { | ||
if (hasRequiredInput) return input; | ||
hasRequiredInput = 1; | ||
Object.defineProperty(input, '__esModule', { value: true }); | ||
input.default = 'x'; | ||
input.foo = 'foo'; | ||
return input; | ||
} | ||
|
||
export { requireInput as __require }; |
15 changes: 11 additions & 4 deletions
15
packages/commonjs/test/fixtures/form/compiled-esm-define-module/output.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,15 @@ | ||
import * as commonjsHelpers from "_commonjsHelpers.js"; | ||
import { __exports as input } from "\u0000fixtures/form/compiled-esm-define-module/input.js?commonjs-exports"; | ||
|
||
Object.defineProperty(input, '__esModule', { value: true }); | ||
var _default = input.default = 'x'; | ||
var foo = input.foo = 'foo'; | ||
var hasRequiredInput; | ||
|
||
export { input as __moduleExports, foo, _default as default }; | ||
function requireInput () { | ||
if (hasRequiredInput) return input; | ||
hasRequiredInput = 1; | ||
Object.defineProperty(input, '__esModule', { value: true }); | ||
input.default = 'x'; | ||
input.foo = 'foo'; | ||
return input; | ||
} | ||
|
||
export { requireInput as __require }; |
13 changes: 10 additions & 3 deletions
13
packages/commonjs/test/fixtures/form/compiled-esm-minified/output.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,14 @@ | ||
import * as commonjsHelpers from "_commonjsHelpers.js"; | ||
import { __exports as input } from "\u0000fixtures/form/compiled-esm-minified/input.js?commonjs-exports"; | ||
|
||
Object.defineProperty(input, '__esModule', { value: !0 }); | ||
var foo = input.foo = 'foo'; | ||
var hasRequiredInput; | ||
|
||
export { input as __moduleExports, foo, input as default }; | ||
function requireInput () { | ||
if (hasRequiredInput) return input; | ||
hasRequiredInput = 1; | ||
Object.defineProperty(input, '__esModule', { value: !0 }); | ||
input.foo = 'foo'; | ||
return input; | ||
} | ||
|
||
export { requireInput as __require }; |
15 changes: 11 additions & 4 deletions
15
packages/commonjs/test/fixtures/form/compiled-esm-only-named/output.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,15 @@ | ||
import * as commonjsHelpers from "_commonjsHelpers.js"; | ||
import { __exports as input } from "\u0000fixtures/form/compiled-esm-only-named/input.js?commonjs-exports"; | ||
|
||
Object.defineProperty(input, '__esModule', { value: true }); | ||
var foo = input.foo = 'bar'; | ||
var bar = input.bar = 'foo'; | ||
var hasRequiredInput; | ||
|
||
export { input as __moduleExports, foo, bar, input as default }; | ||
function requireInput () { | ||
if (hasRequiredInput) return input; | ||
hasRequiredInput = 1; | ||
Object.defineProperty(input, '__esModule', { value: true }); | ||
input.foo = 'bar'; | ||
input.bar = 'foo'; | ||
return input; | ||
} | ||
|
||
export { requireInput as __require }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.